fiting curve/line to vertical line or obtaining coordinates in the unrotated image

1 view (last 30 days)
I'm using polyfit, polyval and fzero to calculate the intercections between a group of line shaped objects in Matlab. I'll show you the image to make myself clear.
From that object I can obtain groups of 4 line shaped objects like this:
I'm able to fit a polynom to each group of 2 objects, unless that so
called group has litle or no change in its x coordinate ( the case when two objects form a vertical line). Now I have searched the problem and I realised that it is not possible to use polyfit for fiting a vertical line. So I tough that rotating the entire image in a way that the vertical objects would stand at an angle would be a possible solution. And so I did. I used imrotate with imcrop for rotating the image 20 degrees and maintaining dimensions, and then calculated the intersections with the above method:
Now the problem is that I need the calculated intersection coordinates but
in the unrotated image referencial. The intersection coordinates have decimal cases, so I cant simply plot a pixel in each one and use imrotate to rotate it back. So I tough aplying a homogeneous transformation matrix in this form
BackT=[ cosd(-20) -sind(-20) TX sind(-20) cosd(-20) TY 0 0 1]
to my intersection coordinates also in homogeneous form.
I think TX and TY would have to be the distances between the center of the image ( because imrotate performs the rotation around the image center) and the image origin (0,0) but im not sure. Also, my image is 800x600, so Im not sure what are its center coordinates.
So to sum up :
-how can I obtain the intersection coordinates in the unrotated image after calculating them in the rotated image.
-is there a way/function of/to fiting a line/curve to the vertical line shaped objects, and this way avoiding rotation of the image ? thank you very much fully apreciated
and sorry for my bad english.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!