I have data in matrix form and I want to assign elements in matrix specific grayscale value( 8-bit, 0 to 256) and than plot a 2D Grayscale image. The function 'mat2gray' assign 0 value to minimum and 1 to maximum but I want to have user-defined value given to elements. [for ex. if my element value is 50 I want to assign grayscale value of 0 to it irrespective whether its minimum or maximum]

댓글 수: 1

Adam
Adam 2017년 7월 18일
편집: Adam 2017년 7월 18일
Just create your own mapping or colourmap then. mat2gray is just a convenience function for the trivial maths of max stretching a data range to the full colourmap range.

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

 채택된 답변

Jan
Jan 2017년 7월 18일
편집: Jan 2017년 7월 18일

0 개 추천

Create a lookup table:
LUT = zeros(1, 256);
LUT(50 + 1) = 1;
Img = randi([0, 100], 200, 100); % Your image
Grey = LUT(Img + 1);
Now the pixels of Img with the value 50 are set to 1.0, and all others to 0.0 . Of course you can adjust LUT arbitrarily.

추가 답변 (0개)

질문:

2017년 7월 18일

편집:

Jan
2017년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by