我正在matlab中構建一個圖像分析圖形用戶界面,其中在一個點上,可以使用imcontrast
工具修改圖像的對比度。接下來,我想自動將此對比度設置應用於其他圖像,這可以使用imshow(image, [min_value max_value])
。因此,我想返回我的程序以從imcontrast
工具返回這些min_value
和max_value
(請參閱下圖)。任何建議如何我可以自動獲得這些值? 如何獲得matlab imcontrast工具的最小值和最大值?
0
A
回答
1
您可以使用imcontrast
返回的figure
句柄來查找包含窗口限制的uicontrols。您可以使用Tag
名稱檢索編輯框句柄,檢索String
屬性並使用str2double
將其轉換爲數字。
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 +你看到括號中的標籤名稱:
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
回調的身影調用自定義的函數來獲取這些值。
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
0
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
相關問題
- 1. 如何獲得矢量中的最大值(或最小值)?
- 2. 如何獲得三維數組的最小值或最大值?
- 3. 如何獲得數組的最小值,最大值?
- 4. 獲取最小值和最大值
- 5. 獲得日期的最小值和最大值的對象
- 6. LINQ - 過濾,分組和獲得最小值和最大值
- 7. 如何聲明具有最小值和最大值的Int?
- 8. OpenCV無法獲得正確的最大值和最小值Mat
- 9. 獲得的最小值和最大值日期
- 10. 獲得密集矩陣元素的最小值和最大值
- 11. 最大值和最小值?
- 12. 如何通過VBA在特定工作表的列中獲得最小(最小)和最大(最大)值
- 13. 如何獲得總和的最大值?
- 14. 具有兩個值(最小值和最大值)範圍的Seekbar
- 15. 如何獲取字符串的最小值和最大值?
- 16. 如何獲取隊列的最小值和最大值?
- 17. 如何獲取輸入的最小值和最大值angularjs
- 18. Highcharts - 如何獲得兩個日期之間的最大值和最小值
- 19. 如何獲得引導滑塊中的最小值和最大值
- 20. 如何分區錶行獲得每個進程的最小值和最大值
- 21. 我如何獲得引導滑塊的最小值和最大值?
- 22. SAS陣列:如何獲得數組子集的總和,最大值,最小值
- 23. 如何獲得引導滑塊的最小值和最大值輸入
- 24. 在MATLAB中查找曲面的最小值和最大值
- 25. 獲取列和其他列值的最小值和最大值
- 26. 如何從jQueryUI Slider中獲取最小值和最大值
- 27. vb.net的最小值和最大值
- 28. NSMutableArray的最小值和最大值
- 29. Java - 最小和最大值
- 30. 具有最小值和最大值的角度過濾器
謝謝你,這有很大幫助!但是,當我手動更改工具中的限制時,這些值不會更新。所以我需要知道數字關閉時的值。任何建議如何實現這一目標? – sdbonte
我現在只是插入一個'while'循環,如果'imcontrast'工具的句柄仍然存在並且更新值,則每循環0.01秒檢查一次。可能有更優雅的解決方案。 – sdbonte
@sdbonte更新了一個如何攔截數字的例子 – Suever