Set of parallel lines in a matrix along different directions(not x and y direction)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (2)
Walter Roberson
el 23 de Jun. de 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 comentarios
Walter Roberson
el 23 de Jun. de 2013
improfile() can take start and end ooordinates as input arguments.
Matt J
el 27 de Jun. de 2013
Editada: Matt J
el 27 de Jun. de 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.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!