Set of parallel lines in a matrix along different directions(not x and y direction)

1 view (last 30 days)
Dear all,
I don't have an idea about how to proceed with this problem! Imagine, I have a 480x748 matrix; I need set of parallel lines along different directions. Set of parallel lines along x and y are clear : rows and columns, respectively. But I need to extract lines in different directions, e.g. 10,20,30,.. from the horizontal. Any MATLAB command or some hints to follow?

Answers (2)

Walter Roberson
Walter Roberson on 23 Jun 2013
Remember the old formula: y = m*x+b and m = tan(theta)
However, if you apply that naively then as you step x by integers, you will get non-integer y coordinates that you will need to make integral. You can floor() or ceil() or round() or fix() to make integral, but as you do so you may end up skipping some integral values (e.g., you might end up selecting y = [1 2 4 5 7 8...]) or you might end up re-using some integral y values. This is likely to throw off your computations.
I suggest you start with something simple like 30 degrees and placing the origin at the logical center of the bottom-left pixel, and computing the exact coordinates you want to be in a single line of length (say) 24. Then switch to 120 degrees and compute again. Now do the logical transpose to compute the lines running perpendicular to those two: is the result one-to-one or do you need to change how you want to define which pixels should be in the lines?
  2 Comments
Mona Mahboob Kanafi
Mona Mahboob Kanafi on 23 Jun 2013
Walter, thanks for your answer.
But, I was searching for something much easier. This takes time, and since I need parallel profiles for at least 20 directions along 2pi, makes the code complex.
I found this command in MATLAB for images (which my data is also a height image), 'IMPROFILE' which gives pixel values along a straight line, but for defining the line, you should specify start and end point of the lines manually. Now, I'm working on it, but one of my problem is, pixel widths along x and y are not the same.

Sign in to comment.


Matt J
Matt J on 27 Jun 2013
Edited: Matt J on 27 Jun 2013
You could also use IMROTATE to rotate the image, so that the lines you want to profile do coincide with the rows/columns of the image matrix.
You could also use griddedInterpolant() or interp2() to sample the desired lines.

Community Treasure Hunt

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

Start Hunting!