void compute_sift_keypoints(float *input, keypointslist& keys, int width, int height, siftPar &par) { flimage image; /// Make zoom of image if necessary float octSize = 1.0f; if (par.DoubleImSize){ //printf("... compute_sift_keypoints :: applying zoom\n"); image = alloc_image<float>(2*width, 2*height); apply_zoom(input,image.data,2.0,par.order,width,height); octSize *= 0.5f; } else image = alloc_image( make_image(input,width,height) ); /// Apply initial smoothing to input image to raise its smoothing to par.InitSigma. /// We assume image from camera has smoothing of sigma = 0.5, which becomes sigma = 1.0 if image has been doubled. /// increase = sqrt(Init^2 - Current^2) float curSigma=0.5f; if (par.DoubleImSize) curSigma *= 2.0f; if (par.InitSigma > curSigma ) { if (DEBUG) printf("Convolving initial image to achieve std: %f \n", par.InitSigma); float sigma = (float)sqrt(par.InitSigma*par.InitSigma - curSigma*curSigma); gaussian_convolution(image.data, image.data, image.w, image.h, sigma); } /// Convolve by par.InitSigma at each step inside OctaveKeypoints by steps of /// Subsample of factor 2 while reasonable image size /// Keep reducing image by factors of 2 until one dimension is /// smaller than minimum size at which a feature could be detected. int minsize = 2 * par.BorderDist + 2; //printf("... compute_sift_keypoints :: maximum number of scales : %d\n", par.OctaveMax); for(int i=(par.DoubleImSize?-1:0); i<=par.OctaveMax && image.w>minsize && image.h>minsize; i++) { if(DEBUG) printf("Calling OctaveKeypoints \n"); OctaveKeypoints(image, octSize, keys,par); // image is blurred inside OctaveKeypoints and therefore can be sampled flimage aux = alloc_image<float>(image.w/2, image.h/2); if(DEBUG) printf("Sampling initial image \n"); sample(image.data, aux.data, 2.0f, image.w, image.h); free(image.data); image = aux; octSize *= 2.0f; } free(image.data); /* printf("sift:: %d keypoints\n", keys.size()); printf("sift:: plus non correctly localized: %d \n", par.noncorrectlylocalized);*/ }
KKeypoint GetKeypoints(Image image) { int minsize; float curSigma, sigma, octSize = 1.0; KKeypoint keys = NULL; /* List of keypoints found so far. */ Image nextImage; PeakThresh = PeakThreshInit / Scales; /* If DoubleImSize flag is set, then double the image size prior to finding keypoints. The size of pixels for first octave relative to input image, octSize, are divided by 2. */ if (DoubleImSize) { image = DoubleSize(image); octSize *= 0.5; } else image = CopyImage(image, IMAGE_POOL); /* Apply initial smoothing to input image to raise its smoothing to InitSigma. We assume image from camera has smoothing of sigma = 0.5, which becomes sigma = 1.0 if image has been doubled. */ curSigma = (DoubleImSize ? 1.0 : 0.5); if (InitSigma > curSigma) { sigma = sqrt(InitSigma * InitSigma - curSigma * curSigma); GaussianBlur(image, sigma); } /* Examine one octave of scale space at a time. Keep reducing image by factors of 2 until one dimension is smaller than minimum size at which a feature could be detected. */ minsize = 2 * BorderDist + 2; while (image->rows > minsize && image->cols > minsize) { keys = OctaveKeypoints(image, & nextImage, octSize, keys); image = HalfImageSize(nextImage); octSize *= 2.0; } /* Release all memory used to process this image. */ FreeStoragePool(IMAGE_POOL); return keys; }
void compute_sift_keypoints(float *input, keypointslist& keypoints, int width, int height, siftPar &par) { flimage image; /// Make zoom of image if necessary float octSize = 1.0; if (par.DoubleImSize){ //printf("... compute_sift_keypoints :: applying zoom\n"); // image.create(2*width, 2*height); // apply_zoom(input,image.getPlane(),2.0,par.order,width,height); // octSize *= 0.5; printf("Doulbe image size not allowed. Guoshen Yu\n"); exit(-1); } else { image.create(width,height,input); } // printf("Using initial Dog value: %f\n", par.PeakThresh); // printf("Double image size: %d\n", par.DoubleImSize); // printf("Interpolation order: %d\n", par.order); /// Apply initial smoothing to input image to raise its smoothing to par.InitSigma. /// We assume image from camera has smoothing of sigma = 0.5, which becomes sigma = 1.0 if image has been doubled. /// increase = sqrt(Init^2 - Current^2) float curSigma; if (par.DoubleImSize) curSigma = 1.0; else curSigma = 0.5; if (par.InitSigma > curSigma ) { if (DEBUG) printf("Convolving initial image to achieve std: %f \n", par.InitSigma); float sigma = (float) sqrt((double)(par.InitSigma * par.InitSigma - curSigma * curSigma)); gaussian_convolution( image.getPlane(), image.getPlane(), image.nwidth(), image.nheight(), sigma); } /// Convolve by par.InitSigma at each step inside OctaveKeypoints by steps of /// Subsample of factor 2 while reasonable image size /// Keep reducing image by factors of 2 until one dimension is /// smaller than minimum size at which a feature could be detected. int minsize = 2 * par.BorderDist + 2; int OctaveCounter = 0; //printf("... compute_sift_keypoints :: maximum number of scales : %d\n", par.OctaveMax); while (image.nwidth() > minsize && image.nheight() > minsize && OctaveCounter < par.OctaveMax) { if (DEBUG) printf("Calling OctaveKeypoints \n"); OctaveKeypoints(image, octSize, keypoints,par); // image is blurred inside OctaveKeypoints and therefore can be sampled flimage aux( (int)((float) image.nwidth() / 2.0f) , (int)((float) image.nheight() / 2.0f)); if (DEBUG) printf("Sampling initial image \n"); sample(image.getPlane(), aux.getPlane(), 2.0f, image.nwidth(), image.nheight()); image = aux; octSize *= 2.0; OctaveCounter++; } /* printf("sift:: %d keypoints\n", keypoints.size()); printf("sift:: plus non correctly localized: %d \n", par.noncorrectlylocalized);*/ }