My GUI is used to display DICOM images. I want to draw lines on top of the image displayed in the GUI. For instance my GUI allows the user to input an angle theta. I want to draw a line on top of the figure which makes an angle theta with the x axis. How do I go about doing that?
I know I can draw lines using the line( ) command but somehow the line that gets drawn appears random not at the angle I specified. I would greatly appreciate some guidance.
No products are associated with this question.
You can use line() or plot()
Remember that line() and plot() use data coordinates. Images drawn with imshow() or image() or imagesc() also use data coordinates, but keep in mind that if the image was the first thing you drew in the axis and you did not specify coordinate positions for the image, then the axis data coordinates will be set as 1 to rows(Image) and 1 to columns(Image).
line() and plot() do not accept angles as input. If you want to draw by angle, use pol2cart([0 angle], [0 linelength]) and add the x/y coordinates of the origin of the line to the result.
Also make sure you use
so that you get square pixels for the image; otherwise the output angles would not appear random but they would be stretched horizontally or vertically.