create a picture with matrix

조회 수: 3 (최근 30일)
Leon Phung
Leon Phung 2018년 6월 7일
답변: Walter Roberson 2018년 6월 7일
Is it possible to create a black&white image from a matrix with 0 and 1? for example, matrix 50x25 (each element represent a pixel) randomly filled with 0 and 1 (assume black = 0 and white = 1), then use that to draw a picture.

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 7일
image(uint8(YourMatrix))
colormap(gray(2))

추가 답변 (1개)

Rishabh Rathore
Rishabh Rathore 2018년 6월 7일
Here's what I understand from your question, you have a matrix of 0s and 1s and want to generate a binary (black and white) image.
You can convert any 2d matrix to grayscale (black and white) image using 'mat2gray' function
And since your matrix only contains 0 or 1 so your image would contain only black or white, no gray levels.
For more information on mat2gray, refer mat2gray
  댓글 수: 1
Leon Phung
Leon Phung 2018년 6월 7일
thank you very much.

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

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by