imcontrast - how to return the level values?

4 ビュー (過去 30 日間)
arnold
arnold 2013 年 12 月 9 日
編集済み: Cris LaPierre 2023 年 7 月 24 日
Hi!
I have been using imcontrast
quite a bit over the years as it is a very handy tool for users to visibly adjust the threshold level for image segmentation. Here is my standard function:
im2bw(fn_image_leveling(testimage), 0.5);
function out = fn_img_leveling(img)
h=figure;
imagesc(img); colormap(hot);
axis image;
uiwait(imcontrast); % set levels
out = getimage(h);
out(out==0)=nan;
close(h);
In my current project I want to let the user set a threshold value for the first image and then apply it to many images. I can't seem to figure out though, how to get the threshold value a user sets using imcontrast. The way I see it the function is not intended to be used like this though :(
Does anyone have an idea how to solve this? I really need a live preview of the adjustable thresholding for it to work.
kind regards, Arnold
  1 件のコメント
arnold
arnold 2013 年 12 月 11 日
nobody an idea?

サインインしてコメントする。

回答 (3 件)

Mitchell Anderson
Mitchell Anderson 2018 年 10 月 30 日

I find them buried deep in the object hierarchy.

        temp = imcontrast;
        ContrastMax = str2num(temp.Children(1).Children(3).Children.Children(2).Children.Children(2).Children(2).String)
        ContrastMin = str2num(temp.Children(1).Children(3).Children.Children(2).Children.Children(2).Children(5).String)

Image Analyst
Image Analyst 2013 年 12 月 11 日
See my interactive thresholding app: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 It returns the values after which you can use them in imadjust() to process the rest of the images in batch mode.
Otherwise it looks like you'll have to ask the user to input the values via inputdlg() so that you can then use imadjust().

Cris LaPierre
Cris LaPierre 2023 年 7 月 24 日
編集済み: Cris LaPierre 2023 年 7 月 24 日
A slightly simpler way to access them is to use findobj with the Tag string:
htool = imcontrast;
contrastMin = findobj(htool,'Tag','window min edit').String
contrastMax = findobj(htool,'Tag','window max edit').String
Other tags of interst might be
  • 'window center edit'
  • 'window width edit'

カテゴリ

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