Phillip
Posts:
12
Registered:
8/2/10


Re: Image rotation detection probelm
Posted:
Nov 28, 2012 5:33 PM


Hi Darren,
Is it a coincidence that the peak of your crosscorrelation appears to be at ~360, or are you getting that confused with the angular expanse of the polar image? What is the array size?
To avoid confusion you should not "hard code" these numbers. eg for one of your lines I would replace: cc1_Matrix = cc_Matrix(130:150,340:380);
With something like: cc1_Matrix = cc_Matrix(rowCentre  roiDiam/2 : rowCentre + roiDiam/2, colCentre  roiDiam/2 : colCentre + colDiam/2);
You also have to calculate the angle based on the ntheta input to the polartrans function. For example, if you specified ntheta = 720, each position in the array would be worth 0.5 deg.
So instead of: Angle_of_rotation = 340+a360
Try (I think):
Angle_of_rotation = (a + colCentre  xSize/2) * 360/ntheta
Where xSize is the diameter of the whole array.
Make sure you get an angle of zero for the test case where the images are the same.
"Darren g" wrote in message <k93t79$7d3$1@newscl01ah.mathworks.com>... > 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 = maxColumn360 % 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+a360 > 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

