首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何求出matlab增强工具的最小值和最大值?

如何求出matlab增强工具的最小值和最大值?
EN

Stack Overflow用户
提问于 2016-08-23 11:55:37
回答 2查看 1K关注 0票数 0

我正在建立一个图像分析图形界面在matlab中,在其中的一点,图像的对比度可以修改使用imcontrast工具。接下来,我想将此对比度设置自动应用于其他图像,这在imshow(image, [min_value max_value])中是可能的。因此,我想返回我的程序,从min_value工具返回这些max_valueimcontrast (见下图)。有什么建议可以让我自动得到这些值吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-08-23 12:31:50

您可以使用由figure返回的imcontrast句柄来查找包含窗口限制的uicontrols。您可以使用Tag名称检索编辑框句柄,检索String属性并使用str2double将其转换为数字。

代码语言:javascript
运行
复制
hfig = imcontrast(gca);
window_min = str2double(get(findobj(hfig, 'tag', 'window min edit'), 'String'));
window_max = str2double(get(findobj(hfig, 'tag', 'window max edit'), 'String'));

另外,我发现标记名的方式是使用以下方式在2014b+中可以看到括号中的标记名:

代码语言:javascript
运行
复制
findobj(hfig, 'style', 'edit')

%   UIControl    (max data range edit)
%   UIControl    (min data range edit)
%   UIControl    (outlier percent edit)
%   UIControl    (window center edit)
%   UIControl    (window width edit)
%   UIControl    (window max edit)
%   UIControl    (window min edit)

至少自R2008a以来,标记名似乎没有发生任何变化。

更新

如果要在关闭时获取值,可以使用图形的CloseRequestFcn回调来调用自定义函数来检索这些值。

代码语言:javascript
运行
复制
set(hfig, 'CloseRequestFcn', @(s,e)getValues(s))

function getValues(hfig)
    window_min = str2double(get(findobj(hfig, 'tag', 'window min edit'), 'String'));
    window_max = str2double(get(findobj(hfig, 'tag', 'window max edit'), 'String'));
end
票数 1
EN

Stack Overflow用户

发布于 2016-10-03 19:05:26

代码语言:javascript
运行
复制
Here is the code I have for this:

close all
clear all
I=imread('pout.tif');
imshow(I);

%--------------
ifig = gcf; % Change here
%--------------

hfig_imcontrast = imcontrast(gca);

set(hfig_imcontrast, 'CloseRequestFcn', @(s,e)getValues(s))
%--------------
set(ifig, 'CloseRequestFcn', @(s,e)closeFig(s,hfig_imcontrast)) % Change here

findall(hfig_imcontrast)
uiwait(hfig_imcontrast)

window_min
window_max

I_bit_depth = class(I);
I_colormap = gray(double(intmax(I_bit_depth)));
imshow(imadjust(I,[I_colormap(window_min);I_colormap(window_max)],[]));

%%%%%%%%%%%%%%%
function closeFig(hfig,ifig)
close(ifig);
close(hfig);
end

%%%%%%%%%%%%%%%%
function getValues(hfig)
    window_min = str2double(get(findobj(hfig, 'tag', 'window min edit'), 'String'));
    window_max = str2double(get(findobj(hfig, 'tag', 'window max edit'), 'String'));

    assignin('base', 'window_min', window_min);
    assignin('base', 'window_max', window_max);
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39100499

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档