Adjusting CData to match CLim for grayscale Image

조회 수: 3 (최근 30일)
John
John 2016년 4월 21일
댓글: John 2016년 4월 22일
I have a grayscale image in a figure displayed through imshow. I adjust the axes CLim limits [a b] to improve it's contrast to desired levels. How can I adjust the image matrix (CData) to match the image displayed by my CLim limits? I've tried imadjust function i.e. Image2=imadjust(Image1,[a b],[]) , but the resultant Image2 contrast doesn't look like the one displayed by CLim limits [a b].

채택된 답변

Walter Roberson
Walter Roberson 2016년 4월 21일
t = double(max(min(Image1, b),a));
adjusted_image = (t - a) / (b - a);
now adjusted_image is in the range 0 (corresponding to a) to 1 (corresponding to b). Remember to caxis([0 1])
  댓글 수: 1
John
John 2016년 4월 21일
Exactly what I was looking for. I had a brain freeze :)
Thanks

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

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 4월 21일
What are you trying to do? If you want to stretch contrast, you can pass in the values you want for black and white into imshow(). Or else call caxis(). I don't understand why you would ask what you asked.
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 4월 22일
The intermediate images probably would not be too large.
John
John 2016년 4월 22일
Thanks Robert. I had the GUI ready, just needed that part of adjusting the matrix. I've employed the mat2gray. I agree the caxis is more efficient, but I'm working with very small images (about 128x128pixel, 8bit) so in the end, the memory isn't an issue for now. I'll implement your suggestion if need be in the future.

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

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by