⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apply_filters.c

📁 一个有关eigenface的matlab 例程
💻 C
字号:
/*======================================================================
  apply_filters.c
 
  written by David Bolme - Colorado State University
  
  This code is used to extract regularly spaced gabor jets from a
  normalized face image. 
  
  Usage: apply_filters nrm_image gabor_image
  
  The program creates a file (gabor_image) of SUN floating point values that
  corispond to 675 gabor jets of length 32 each.  
 
======================================================================*/


#include <stdio.h>
#include <math.h>
#include "feretio.h"

#define IMAGE_W 130
#define IMAGE_H 150


/* =====================================================================
  function apply_mask*()

  These are automaticaly generated function that applies a gabor filter
  to a specific point on the image.  Source code for the function can
  be found in mask*.c

===================================================================== */

float apply_mask0even(float*,int,int,int,int);
float apply_mask1even(float*,int,int,int,int);
float apply_mask2even(float*,int,int,int,int);
float apply_mask3even(float*,int,int,int,int);
float apply_mask4even(float*,int,int,int,int);
float apply_mask5even(float*,int,int,int,int);
float apply_mask6even(float*,int,int,int,int);
float apply_mask7even(float*,int,int,int,int);
float apply_mask8even(float*,int,int,int,int);
float apply_mask9even(float*,int,int,int,int);
float apply_mask10even(float*,int,int,int,int);
float apply_mask11even(float*,int,int,int,int);
float apply_mask12even(float*,int,int,int,int);
float apply_mask13even(float*,int,int,int,int);
float apply_mask14even(float*,int,int,int,int);
float apply_mask15even(float*,int,int,int,int);
float apply_mask0odd(float*,int,int,int,int);
float apply_mask1odd(float*,int,int,int,int);
float apply_mask2odd(float*,int,int,int,int);
float apply_mask3odd(float*,int,int,int,int);
float apply_mask4odd(float*,int,int,int,int);
float apply_mask5odd(float*,int,int,int,int);
float apply_mask6odd(float*,int,int,int,int);
float apply_mask7odd(float*,int,int,int,int);
float apply_mask8odd(float*,int,int,int,int);
float apply_mask9odd(float*,int,int,int,int);
float apply_mask10odd(float*,int,int,int,int);
float apply_mask11odd(float*,int,int,int,int);
float apply_mask12odd(float*,int,int,int,int);
float apply_mask13odd(float*,int,int,int,int);
float apply_mask14odd(float*,int,int,int,int);
float apply_mask15odd(float*,int,int,int,int);

int main( int argc, char** argv ) {
    float* image;
    float* output;
    int i,j,n;
    
    
    if(argc != 3){ 
    	printf("usage: %s infile outfile\n",argv[0]);
    	exit(1);
    }
    image = readferetraster(argv[1],IMAGE_W*IMAGE_H);
    output = (float*)malloc(sizeof(float)*IMAGE_W*IMAGE_H*2);
    n = 0;
    for( i = 4; i < IMAGE_W-4; i+= 5){
        for(j = 9; j < IMAGE_H-9; j+=5){
//    for( i = 0; i < IMAGE_W; i++){
//        for(j = 0; j < IMAGE_H; j++){
            output[n++] = apply_mask0even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask1even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask2even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask3even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask4even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask5even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask6even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask7even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask8even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask9even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask10even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask11even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask12even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask13even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask14even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask15even(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask0odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask1odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask2odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask3odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask4odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask5odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask6odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask7odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask8odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask9odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask10odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask11odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask12odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask13odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask14odd(image,IMAGE_W,IMAGE_H,i,j);
            output[n++] = apply_mask15odd(image,IMAGE_W,IMAGE_H,i,j);
            //output[i + j * IMAGE_W] =0;
            //printf("%f ",output[i + j * IMAGE_W]);
        }
    }
    //printf("Samples: %d\n",n);
    writeferetraster(argv[2],output,n);
    
    free(output);
    free(image);
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -