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

1 回表示 (過去 30 日間)
Mona Mahboob Kanafi
Mona Mahboob Kanafi 2013 年 6 月 23 日
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?

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 6 月 23 日
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 件のコメント
Mona Mahboob Kanafi
Mona Mahboob Kanafi 2013 年 6 月 23 日
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.
Walter Roberson
Walter Roberson 2013 年 6 月 23 日
improfile() can take start and end ooordinates as input arguments.

サインインしてコメントする。


Matt J
Matt J 2013 年 6 月 27 日
編集済み: Matt J 2013 年 6 月 27 日
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.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by