How do I link an image and a histogram of that image so the histogram only represents what is shown in the image, i.e. if I zoom in on the image, the histogram updates?
1 次查看(过去 30 天)
显示 更早的评论
I have a gui with two axes, an image (created using imagesc) and a histogram of that image. I want to add a menu item that will allow the user to turn on/off the ability to link the histogram to the image so if the user zooms in/out, the histogram automatically updates with the image data that is shown (and ignore the image data that is not shown).
I am using Matlab 2016a.
Any suggestion is welcome.
Thanks!
0 个评论
采纳的回答
更多回答(1 个)
Image Analyst
2017-6-15
Use an imscrollpanel to contain your image and then call "getVisibleImageRect()":
% Here's the example from the documentation:
% Create a scroll panel with a Magnification Box and an Overview tool.
hFig = figure('Toolbar', 'none',...
'Menubar', 'none');
hIm = imshow('saturn.png');
hSP = imscrollpanel(hFig,hIm); % Handle to scroll panel.
set(hSP,'Units', 'normalized',...
'Position', [0, .1, 1, .9])
% Add a Magnification Box and an Overview tool.
hMagBox = immagbox(hFig, hIm);
boxPosition = get(hMagBox, 'Position');
set(hMagBox,'Position', [0, 0, boxPosition(3), boxPosition(4)])
imoverview(hIm)
% Get the scroll panel API to programmatically control the view.
api = iptgetapi(hSP);
% Get the current magnification and position.
mag = api.getMagnification();
r = api.getVisibleImageRect();
The full demo is attached.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!