필터 지우기
필터 지우기

Draw a binary image

조회 수: 22 (최근 30일)
Anna
Anna 2013년 8월 30일
댓글: Image Analyst 2022년 12월 2일
I want to draw an image of vertical stripes using the pattern 11001100111000. If 1 represents a black bar and 0 represents a white bar, how can I draw a black and white image using black with an intensity value of 0 and white with an intensity value of 1? Assume the image is 100 pixels long and assume 1 pixel is 1 bar.
An example of a code would be great, thanks.
  댓글 수: 1
Jan
Jan 2013년 8월 30일
How could the image have 100 pixels with one pixel per bar, if the pattern has 14 elements only?

댓글을 달려면 로그인하십시오.

답변 (3개)

Iain
Iain 2013년 8월 30일
image_i_want = [1 1 0 0 1 1 0 0 1 1 1 0 0 0 ...put in the rest of your pattern... ];
imagesc(image_i_want)
You probably want a more complicated answer...
  댓글 수: 1
Muthu Annamalai
Muthu Annamalai 2013년 8월 30일
편집: Muthu Annamalai 2013년 8월 30일
I'll just say, augment the code from @Iain with,
>> colormap gray >> imagesc(image_i_want)
@Anna if you want more control of rectangle objects, borders, shading, filling etc, look at http://www.mathworks.com/help/matlab/ref/rectangle.html to get your b/w images.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2013년 8월 30일
Try this:
desiredOutputColumns = 640; % Whatever....
desiredOutputRows = 480; % Whatever.....
pattern = [1,1,0,0,1,1,0,0,1,1,1,0,0,0];
stripeImage = imresize(pattern, [desiredOutputRows, desiredOutputColumns], 'nearest');
imshow(stripeImage, [])
I'm not sure if you want 0 to be black and 1 to be white, or vice versa - your message was ambiguous on tat point. Anyway, it's trivial to adapt the above code.
  댓글 수: 20
Image Analyst
Image Analyst 2021년 5월 19일
@Ayush singhal, probably, though I'm not going to have time to figure it out for you, sorry.
Ayush singhal
Ayush singhal 2021년 5월 19일
Okah Thanks.

댓글을 달려면 로그인하십시오.


Shambhuraj
Shambhuraj 2022년 12월 2일
How to 3-D heart under name
  댓글 수: 1
Image Analyst
Image Analyst 2022년 12월 2일
See attached demos and adapt as needed.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by