Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to calculate the angle between two images?
Replies: 41   Last Post: Dec 8, 2012 11:02 PM

 Messages: [ Previous | Next ]
 Dave Robinson Posts: 1,338 Registered: 1/25/05
Re: How to calculate the angle between two images?
Posted: Apr 3, 2009 10:15 AM

"khoo" <jim_khoo@hotmail.com> wrote in message <gr544d\$5vk\$1@fred.mathworks.com>...
> > No I don't have any Matlab code I can give you, I make it a policy not to do this. You need to write your own software in order for you to be able to master the craft - just like all of the Guru's here had to.
> >
> > What I am saying in those two sentences is every pixel in the image has an angle calculated using the atan2 operation. However these angles in regions of the image that are featureless have no meaning, they are purely due to noise in the imaging process. This means we need some way of identifying real angles and meaningless angles. Real angles occur where we have edges, so if we pass both original images through an edge detector such as edge(canny) or edge(sobel) and then 'make the indicated edges slightly fatter using the correct morphology operator, then it follows that if we lay this modified edge image over its corresponding angle image, then angle values corresponding to the pixels hilighted in the edge image correspond to angles we can believe in. Those in areas where there are no edges cannot be trusted.
> >
> > Now you need to make 2 histograms (one from each of your angle images) of your trusted angles. What you find is that these histograms are virtually identical, with the exception that they are shifted relative to each other. This shift is equal to the relative rotation of the original images.
> >

>
> i ady done the in front part but stuck at the modified edge image over corresponding angle..i dunno wat function need to be used..i using time but got error..
>
> this is the code i currently obtained so far
>
> im11=rgb2gray(im1);
> im111=im2double(im11);
> p1=atan2(dy,dx);
> im1111=edge(p1,'canny');
> bw1 = bwmorph(im1111,'dilate');
> im=p1*bw1;
> imshow(im)
>
> this is the error messange i got
> ??? Error using ==> mtimes
> Inner matrix dimensions must agree.
>
> so wat the function i need to used??

I am a bit busy to study your code closely right at the moment, but what seem to be a problem is
im=p1*bw1;
I would have thought that it should read
im=p1.*bw1;

The dot before the * is kind of crucial check the help files.

By the way I am impressed with the speed at which you converted my description into code, it might not have worked first time, but this is the only way to really get to grips with a very powerful problem solving tool

Well done

Dave Robinson

Date Subject Author
4/3/09 khoo
4/3/09 Dave Robinson
4/3/09 khoo
4/3/09 Dave Robinson
4/3/09 khoo
4/3/09 Dave Robinson
4/3/09 khoo
4/3/09 khoo
4/4/09 khoo
4/4/09 Dave Robinson
4/4/09 khoo
4/4/09 khoo
4/5/09 khoo
4/5/09 Dave Robinson
4/5/09 khoo
4/5/09 khoo
4/5/09 Dave Robinson
4/5/09 khoo
4/6/09 khoo
4/6/09 Dave Robinson
4/6/09 khoo
4/6/09 Dave Robinson
4/6/09 khoo
4/6/09 Dave Robinson
4/6/09 khoo
4/6/09 khoo
4/6/09 khoo
4/7/09 khoo
4/7/09 khoo
4/7/09 Dave Robinson
12/8/12 Jeff
4/3/09 Skeptic
4/3/09 Dave Robinson
4/3/09 Roger Stafford
4/3/09 khoo
4/3/09 Roger Stafford
4/3/09 ImageAnalyst
4/3/09 khoo
4/4/09 khoo
4/6/09 Matt
4/6/09 khoo
4/6/09 Matt