How can I generate an image with multiple lines?

2 views (last 30 days)
I am generating a fibre system, so I need to create an image with multiple lines but the sad part is I only get one line. Can anybody body help me in this regard the part of the code which is used to generate the image is given below:
Inside the loop:
mat = zeros(250,250,'uint8');
x = prev(1):new(1); %# x values at a higher resolution
m= (new(2)-prev(2))/(new(1)-prev(1));
y = m*x+prev(2); %# corresponding y values
index = sub2ind(size(mat),round(y),round(x)); %# Indices of the line
mat(index) = 255; %# Set the values to the max value of 255 for uint8
Loop ends here
image(mat); %# Show original line image
colormap(gray); %# Change colormap

Answers (2)

Walter Roberson
Walter Roberson on 29 Jun 2015
Move the
mat = zeros(250,250,'uint8');
to before the loop.

Image Analyst
Image Analyst on 29 Jun 2015
Use imline() to burn lines into an image. See attached demo for full instructions/tutorial.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!