Making a grayscale matrix
이전 댓글 표시
I am trying to create a grayscale matrix.
I would like to have an M by N matrix. The gray scale is from [0 255]. I would like to be able to change the entire color of the matrix to a number matching the grayscale.
For example (1)I have a 5 by 5 matrix (2)I grayscale number to be half of [ 0 255] so 128 (3)I need the entire matrix to show the 128 color. (4)I also need to be able to change the input number from the grayscale.
How do I do this. I tried but I can't get the entire matrix to be one color.
답변 (1개)
Geoff Hayes
2016년 2월 25일
Perhaps I'm misunderstanding, but it seems that you are trying to just assign the same value to all elements within your matrix. For example,
gsMtx = uint8(zeros(512,512));
image(gsMtx);
colormap(gray(256));
would create a black image. If we change this so that all elements of gsMtx are 128, then we would do
gsMtx(:,:) = 128;
image(gsMtx);
colormap(gray(256));
which would create a gray image.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!