1

I would like to draw a line, between point1 and point2, also by an angle (for example 15 degrees to the axis x) on an image or matrix. I do not just want to display the line on the image (as with plot). I want to actually change the pixel values so that I can save the image and reload it with the line still there.

Thank You

Wahyu
  • 33
  • 1
  • 4
  • 1
    Duplicates: [MATLAB: Drawing a line over a black and white image](http://stackoverflow.com/q/2464637/52738), [How do I create an image matrix with a line drawn in it in MATLAB?](http://stackoverflow.com/q/1940833/52738) – gnovice Apr 04 '12 at 14:52

1 Answers1

1

If you have the image processing toolbox, you can draw a line between any two points (either interactivly, or by specifying) using the function imline(). You can then save the line using createMask(). This will give you a binary image with only the line. You can then easily subtract, add or change the pixels in the orignal image and save it.

I = im2double(imread('pout.tif'));        %Read Image
imshow(I,[])
h = imline(gca,[10 100], [80 100]);       %Create line
Line = createMask(h);                     %Extract binary line
I = I + Line;                             %Add line to orignal image
Ghaul
  • 3,340
  • 1
  • 19
  • 24
  • Hi Ghaul...Thanks for your suggestion. unfortunately I don't have createMask() function. any alternative for that? – Wahyu Apr 04 '12 at 23:11