sthoduka / imreg_fmt Goto Github PK
View Code? Open in Web Editor NEWImage registration based on the Fourier-Mellin transform
Home Page: https://sthoduka.github.io/imreg_fmt/
License: GNU General Public License v3.0
Image registration based on the Fourier-Mellin transform
Home Page: https://sthoduka.github.io/imreg_fmt/
License: GNU General Public License v3.0
Hi @sthoduka,
Thank you for providing and maintaining this reference code. It has helped me understand better how Fourier Mellin transform works and how robust it can be given noise in image evaluation. 😄
I do note that the code is meant to compile only with OpenCV 2.4. Therefore, this issue is only created to justify a pull request I will be making shortly.
When attempting to compile the code using OpenCV 4.2, it generates the following error.
# Compiling the code
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
/home/user/imreg_fmt/src/image_transforms.cpp: In member function ‘void ImageTransforms::remapLogPolar(const cv::Mat&, cv::Mat&)’:
/home/user/imreg_fmt/src/image_transforms.cpp:52:43: error: ‘CV_INTER_CUBIC’ was not declared in this scope
52 | cv::remap(src, dst, cv_xMap, cv_yMap, CV_INTER_CUBIC & cv::INTER_MAX, cv::BORDER_CONSTANT, cv::Scalar());
This build failure is caused by the fact I am using OpenCV 4.2 and therefore some MACROS in OpenCV 2.4 are not present in newer versions.
This issue is addressed by Pull Request #7.
I've found a small typo in the documentation, in:
https://sthoduka.github.io/imreg_fmt/docs/fourier-mellin-transform/
In the second-to-last equation, where you calculate the angle, instead of pi, you need to use 180 if the result is to be calculated in degrees.
Thanks!
Hi, thank you for your contribution.
I have a question about the meaning of the result. I just use a sequence of images and get a series of the result from image_main. I found that if I draw the trajectory as x and y are global pose, it looks good. But as I understand that x and y should be a translation from the last pose right? I am not sure..
Could you give me some suggestions about this? thank you!
Thank you for a very useful contribution- this is the only one I found that implements the phase correlation on log-polar images in C++.
I was trying to use it to emulate Matlab function imregcorr(). There are some obvious differences- this code accepts only the images that are the same size, and does not return the peak correlation coefficient. Any pointers how to resolve this would be greatly appreciated.
I found that the code runs into problems for certain image sizes. For example, if you resize im0 and im1 provided with the source code to be 897x1151 (width x height), function Eigen::MatrixXd ImageDFT::neighbourhood() will try to use a negative index in a wrap-around section of the code, causing an assertion eigen_assert(row >= 0 && row < rows() && col >= 0 && col < cols());
Can you let me know how did you compute the Fourier Mellin transform?
cmake -DCMAKE_BUILD_TYPE=Release ..
Hi @sthoduka
There is no scale transformation in my image data. I want to fix the scale. How can I do this?
I would like to know why you have not used OpenCV warpPolar
method and implemented it by yourself.
I am trying to understand why I cannot use the OpenCV warpPolar
instead.
Hey. Thanks for the effort on this. It saved me lots of time.
I need a number to tell me how much the images are similar. For example, OpenCV phaseCorrelate
returns a double(response
) that can be used as a similarity indication.
I was thinking of using this similar to phaseCorrelation
response, but I cannot figure out the right way to use it.
From OpenCV doc:
the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.
response: Signal power within the 5x5 centroid around the peak, between 0 and 1 (optional).
Please use OpenCV's provided phaseCorrelate function to improve performance.
With minor changes I improved the running time of registerImage
from 316ms to 93ms, or ~3.4x improvement. (1280x720, 100 runs, averaged.) Changes in image_registration.cpp:
auto[rs_col, rs_row] = cv::phaseCorrelate(im1_logpolar_, im0_logpolar_);
image_transforms_.getScaleRotation(-rs_row, -rs_col, scale, rotation);
, and:
auto[t_col, t_row] = cv::phaseCorrelate(im1_gray_, im0_rotated_);
image_transforms_.translate(im0_rotated_, registered_image, -t_col, -t_row);
I see no reason to implement phase correlation here. The implementation in OpenCV is different (see link), but the difference of the output transformation parameters is marginal.
As a side note, using OpenCV would also allow for outputting the confidence of the transform with the signal power around the peak 5x5:
double response;
auto[t_col, t_row] = cv::phaseCorrelate(im1_gray_, im0_rotated_, cv::noArray(), &response);
transform_params[4] = response;
OpenCV documentation for phaseCorrelate: https://docs.opencv.org/4.x/d7/df3/group__imgproc__motion.html#ga552420a2ace9ef3fb053cd630fdb4952
Implementation of OpenCV phaseCorrelate: https://github.com/opencv/opencv/blob/d7a237aefc76f841dba64544d09ab6df53097206/modules/imgproc/src/phasecorr.cpp#L518
Edit: Code highlight
hello.i am working on a project in java using openCV and i have calculated the DFT in Cartesian coordinates of an image and now i want to convert that into Log-polar coordinates. i have attached the DFT magnitude image that i have calculated in DFT and now i want to convert that into Log-polar coordinates. Any type of help would be appreciated.
In paper the peak should greater than 0.03.
So i want to know how to get it, it should be an interface.
Can the running speed be further optimized? Running efficiency is too slow
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.