ZeLianWen / Image-Registration

Image registration algorithm. Includes SIFT, SAR-SIFT,PSO-SIFT.
531 stars 126 forks source link

How to change your data format #4

Open standarm opened 6 years ago

standarm commented 6 years ago

I note if I change all CV_32FC1 in your code into CV_16SC1, then the programe can save a lot memory consumption. But the sift_1.detect will fail to get that keypoints_1 in following. How to change the other code for the change?

ZeLianWen commented 6 years ago

Thanks for you attention. My english is poor, please see the function "create_initial_image" where "gray_image.convertTo(floatImage, CV_32FC1, 1.0 / 255.0, 0)" is express. This means we must convert the image to floating point type, 1.0 / 255.0 means the range is 0 to 1 after converted. So you must ensure the convertTo function support CV_S16C1. You should ensure the date type is identical .

If you want reduce the memory consume, i suggest you pay attention to the following aspects:

  1. sift.cpp->num_octaves->temp = cvRound(log(size_temp) / log((float)2) - 2) you can reduce the layer, it is temp, modified it to "temp = cvRound(log(size_temp) / log((float)2) - 3)" or "temp = cvRound(log(size_temp) / log((float)2) - 4)"

  2. main.cpp->MySift sift_1(0, 3, 0.04, 10, 1.6, true) change it to "MySift sift_1(0, 3, 0.04, 10, 1.6, false)"

  3. delete the main.cpp->image_fusion(image_1, image_2, homography, fusion_image, mosaic_image, regist_image) the function image_funct

ZeLianWen commented 6 years ago

main.cpp->gauss_pyr_1, dog_pyr_1 and main.cpp->gauss_pyr_2, dog_pyr_2 is global variables, so you can change it to local variable. you can combine "sift_1.detect" and "sift_1.comput_des".