Comparing cross point between 2 images in MATLAB
I took 2 images with a cross point and now I'm trying to compare these 2 images and f开发者_运维问答ind out what is the distance and angle moved. How can I use MATLAB to do this? Thank you very much!
Aligning two images of the same scene is called image registration. If you have access to the Image Processing Toolbox, you can find there a number of functions to help you.
Take a look at these image registration demos.
If those black lines are always in the images, and they're near perfectly straight (not being distorted into curves), a better method would be to use the Hough transform or Radon transform (kind of different ways to think about doing the same thing) to find just the two black lines, and then compare their positions.
You'd invert the images first, so the lines are bright white (large values), and then do the Hough transform. The output for each image will be two bright white points, from which you can do peak detection. The coordinate of each peak tells you the angle and offset of the line.
I haven't done this in MATLAB, but I see a number of examples and documentation:
- Demo of Hough Transform for straight lines (you don't need to do the edge detection step)
hough
,houghlines
, andhoughpeaks
functions
Cross-correlation (Wikipedia calls it Phase correlation) won't work if the images are rotated. However, there's a related method based on log-polar coordinates that will work regardless of rotation, scale, shear, and translation.
This method would be best if you have to match any arbitrary images. Matching known shapes or dark lines is better done with other methods.
精彩评论