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 Center および File ExchangeExplore 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