line profile on rotated image

Hi, I have an image of about 4000 pixels wide and I want to perform a line scan through the centre (cyan line below)and obtain the intensity profile. My image is slightly twisted. I have tried imrotate but had to do it manually. Is there an automated way where I can for example use the improfile function to create a line on my image so that it goes through the same line of then objects.
in the picture above, you can clearly see that the right hand edge and left hand edge show the cyan line which represents the features in the centre of image, but they depart from the line due to image rotation.
This picture illustrates it a bit better
This just represents a small portion of my image, in reality, the departure from the cyan line at the extreme edges is several features in the y direction.
Thanks for any ideas how I can correctly obtain a line profile. thanks Jason

Respuestas (1)

Image Analyst
Image Analyst el 13 de Mzo. de 2016

1 voto

You can use the radon transform to discover the optimum angle to rotate the image. Then you can just take rows from that to get the profile. I attach an example where I used the radon transform to find the angle and rotate the image.

4 comentarios

Jason
Jason el 16 de Mzo. de 2016
Editada: Jason el 16 de Mzo. de 2016
Unfortunately this didnt work, and it does strange things to the image.
Im keen to use the regioprops approach, but Im struggling to find the two end points that are on the same line.
I need to start from the centre of the image and create the linescans from there (so I have performed 2, one going from centre to extreme left of image, then the second going from centre to extreme right of image.
for i=xs:2*xf %-1 to account for look ahead later
I=ROI(ys,i);
%[i,I]
L(1,i-xs+1)=I;
if (I>maxVal&I>ROI(ys,i+1)) %if bigger than last and than next
maxVal=I;
xpos(1,u)=i;
maxVal=ROI(ys,i+1) ; %Reset maxVal
%look up 1 and 1 down to see if y needs adjusting
if (ROI(ys,i))<(ROI(ys+1,i))
ypos(1,u)=ys+1;
ys=ys+1;
elseif (ROI(ys,i))<(ROI(ys-1,i))
ypos(1,u)=ys-1;
ys=ys-1;
else
ypos(1,u)=ys;
end
u=u+1;
end
end
So the idea is to start at the centre, and use a for loop. in the loop I look at the next pixel to the left and if its higher than previous one keep going until it becomes less, call this a peak and then assign it to my output vector. This nearly works but isn't quite there.
Image Analyst
Image Analyst el 16 de Mzo. de 2016
Just how rotated can this image be? Any angle between 0 and 90 degrees? Or mostly aligned with the image edges? How about if you synthesized a "perfect" image and used imregister() to align the "rotated" image with the "perfect" unrotated synthesized image? Then take rows.
Jason
Jason el 16 de Mzo. de 2016
Editada: Jason el 16 de Mzo. de 2016
The image is only slightly misaligned (rotated) - about 0.26 degrees. A line scan starting at the centre of the image, by the time it reaches the left hand side image has crossed on line of spots.
I do the Synthesizing once I have the intensity profile along the centre of one row of spots. I then use this to calculate distortion (actual "x" location minus real "x" location)
By its nature, distortion gets worse the further from the centre you are, so I'm not convinced that using imregister is the best way as it may be possible to "get out of synch" with the current object and align to the adjacent one.
the reason I like the "improfile" approach is that I directly create a linescan that incorporates the image rotation. I then find the peaks on this profile. Then I generate what the "real" locations should be and subtract these two measurements. These two measurements for a very small FOV are shown below.
where I'm struggling is generating the improfile coordiantes. i start at the centre of field of view, align to nearest object. what I want to do, but can't yet, is to move horizontally away from the starting location, and record the x location of any peaks, but allow for an adjustment in y to find the true location of x - to account for image rotation.
Image Analyst
Image Analyst el 16 de Mzo. de 2016
What I'm saying is to take one image and align it somehow, or synthesize one. So you have one image that you know for a fact is perfectly aligned with the rows. Then use imregister on all the rest of the images to align with that perfectly aligned one. Then you can simply extract rows from the now aligned image. I would think that should work unless your distortion is so extreme that the outer spots maybe nowhere near the reference outer spots while the central ones are pretty much in the same place. In that case you might have to do a rubber sheet stretch with imwarp.
Alternatively just measure the weighted centroids and pass the y values into kmeans() in the Statistics and Machine Learning Toolbox. There are ways to use kmeans to figure out what the best k is if you don't know the number of rows. So now you know the number of rows and you can extract all blobs that have a y value between the cluster mean y values. So now all those spots are on the same line. (I do this very thing for finding chips on an X-rite ColorChecker chart.) Now you can interpolate a path between all the centroids and extract the intensities along that path.

Iniciar sesión para comentar.

Preguntada:

el 4 de Mzo. de 2016

Comentada:

el 16 de Mzo. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by