Find cross section of 2d plot (tilted matrix/image)

Dear MATLAB community,
I do sometimes measurements of the near-field of a laser diode. For high power lasers, the measurement looks like the "2D_Image.jpg" attached. It looks like a stripe of brightness. I am interested in the lateral cross section of that stripe. Usually, when the laser is placed flat, I can just find the max peak and draw the line corresponding to the row index of that point. It would give me something like the "Cross_Section.jpg" attached. However, as we can see in the 2D image, sometimes the camera or the laser are misaligned and it is not flat. Is there a way to automatically find the cross section when the measurement turns out tilted like that, without having to guess the tilted angle (which is never the same) and rotate the image? I also do not have the image processing toolbox.
Thank you very much!
Thiago

Answers (1)

Image Analyst
Image Analyst on 21 Apr 2017
Edited: Image Analyst on 21 Apr 2017
Pretty easy. Just use the radon transform to compute the projection of all angles at once. Then pick whichever angle gives you the highest peak. It will be the mean perpendicular profile that you're looking for. I can't do it for you because you didn't attach the original image, just the pseudocolored one. You need to use the original image.
For what it's worth, I'm attaching a different demo of radon() where I project the image, determine the angle, and use it to unrotate/straighten the image. NOTE: you do NOT need to rotate your image to get it's cross sectional profile - the radon transform is the profile directly. Good luck.
By the way your image does not have 1600 pixels in any direction so I don't know how you got that 1600 element long profile you posted.

3 Comments

Dear Image Analyst,
Thank you very much for your reply. I am going over your m-file, but I realize my MATLAB version does not have the function radon. Does it require the Image Processing Toolbox? Because I do not have it!
About the pixel size, I had zoomed in in the image that is why you do not see more than 1600 pixels in one direction. In fact I do not have an image out of the measurement, I have a 2d matrix with the intensity values on each slot (I attached an example, had to reduce the size of the matrix to be <5MB).
And also, I agree with you that I do not need to rotate the matrix. All I need is that intensity cross section along the stripe.
Thanks again,
Thiago
Not sure if the csv file went through ok!
Not sure how to help if you don't have the Image Processing Toolbox. Another way is to get the intensity profile between two points with improfile(), but that requires the toolbox too.
I guess you'll have to somehow do it manually with interp1 or interp2(), though I'm not sure how. You might check out the Bresenham line algorithm in Wikipedia.

Sign in to comment.

Asked:

on 21 Apr 2017

Commented:

on 24 Apr 2017

Community Treasure Hunt

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

Start Hunting!