Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Image rotation detection probelm
Replies: 32   Last Post: Aug 8, 2013 10:46 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Darren g

Posts: 10
Registered: 11/14/12
Re: Image rotation detection probelm
Posted: Nov 27, 2012 9:34 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi Phillip,

Thank you for the function details for finding the centre of mass. I have used this function within my code to find the centre of mass of the intensity peak region. However, the angular rotation is not resulting correctly but displayed with four decimal places. Below is the part of the code. The maximum intensity is found at column 361 and row 141 for the first two set of images and a small change for the rest.

[max_cc_Matrix, maxColumn] = max(max(cc_Matrix))
[max_cc_Matrix, maxRow] = max(cc_Matrix(:, maxColumn))
%Angle_of_rotation = maxColumn-360 % for finding rotation using the intensity peak.
cc1_Matrix = cc_Matrix(130:150,340:380); % only the region surrounding the
% maximum peak is considered.
[a,b] = find_com(cc1_Matrix) % calling function for finding centre of mass
Angle_of_rotation = 340+a-360
A1(k,:) = [k, Angle_of_rotation];
disp(A)

This will give the image no and the angle of rotation of a set of images.
Any error in calling the function or calculation?

Thanks.
Darren


"Phillip" wrote in message <k91fgr$e3d$1@newscl01ah.mathworks.com>...
> Hi Darren,
>
> Below is a basic function for finding centre of mass, I can not recall where I stole it from. Try to find the centre of mass in a small region of interest around the peak (instead of using the whole array). Just remember to convert back to whole array co-ordinates to give the final displacement.
>
> Phil
>
> function [a,b] = find_com(x,y,A)
>
> % Finds centre of mass of matrix A in x, y index notation
>
> if nargin == 1
> A = x;
> [Ar Ac] = size(A);
> x = 1:Ac;
> y = (1:Ar)';
> else
> y = y(:);
> x = (x(:))';
> end
>
> sumA = sum(A(:));
> if sumA == 0
> a = 0;
> b = 0;
> else
> [row col] = size(A);
> % Find centroid across columns:
> temp = A.*(ones(row,1)*x);
> a = sum(temp(:))/sumA;
> % Across rows:
> temp = A.*(y*ones(1,col));
> b = sum(temp(:))/sumA;
> end
>
> "Darren g" wrote in message <k8v2ok$lam$1@newscl01ah.mathworks.com>...

> > Hi Phillip,
> >
> > Many thanks. Yes. My code is now working after adopting your suggestion for finding the column and row in which the maximum peak intensity is found. For finding the centre of mass of the image to measure the angle of rotation smaller than one degree I am trying the regionprobs but not yet found a way on how to integrate this within my code. Is this the one you mentioned for finding to centre of mass or any other easy way of doing? Your help for this is much appreciated.
> >
> > Darren



Date Subject Author
6/19/09
Read Image rotation detection probelm
Pradyumna A
6/19/09
Read Re: Image rotation detection probelm
Matt
9/16/09
Read Re: Image rotation detection probelm
Hamid Reza Mohseni Nejad
8/2/10
Read Re: Image rotation detection probelm
Phillip
12/21/10
Read Re: Image rotation detection probelm
chee ali
12/21/10
Read Re: Image rotation detection probelm
Phillip
12/21/10
Read Re: Image rotation detection probelm
Matt J
12/21/10
Read Re: Image rotation detection probelm
Phillip
11/14/12
Read Re: Image rotation detection probelm
Darren g
11/14/12
Read Re: Image rotation detection probelm
Phillip
11/19/12
Read Re: Image rotation detection probelm
Darren g
11/19/12
Read Re: Image rotation detection probelm
Phillip
11/20/12
Read Re: Image rotation detection probelm
Darren g
11/20/12
Read Re: Image rotation detection probelm
Phillip
11/26/12
Read Re: Image rotation detection probelm
Darren g
11/26/12
Read Re: Image rotation detection probelm
Phillip
11/27/12
Read Re: Image rotation detection probelm
Darren g
11/28/12
Read Re: Image rotation detection probelm
Phillip
11/29/12
Read Re: Image rotation detection probelm
Darren g
12/2/12
Read Re: Image rotation detection probelm
Phillip
12/3/12
Read Re: Image rotation detection probelm
Darren g
12/4/12
Read Re: Image rotation detection probelm
Phillip
12/11/12
Read Re: Image rotation detection probelm
Darren g
12/11/12
Read Re: Image rotation detection probelm
Phillip
12/12/12
Read Re: Image rotation detection probelm
Darren g
12/12/12
Read Re: Image rotation detection probelm
Steven Lord
2/6/13
Read Re: Image rotation detection probelm
Darren g
12/20/12
Read Re: Image rotation detection probelm
Phillip
12/20/12
Read Re: Image rotation detection probelm
Kev
12/20/12
Read Re: Image rotation detection probelm
Kev
7/7/13
Read Re: Image rotation detection probelm
xmlfor
8/8/13
Read Re: Image rotation detection probelm
jacaboo

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.