File Exchange

image thumbnail

Add an ROI toolbar to your figure

version 1.3 (622 KB) by

This function adds an ROI toolbar to your figure.

7 Downloads

Updated

View License

This function adds an ROI toolbar to your figure.
The ROIs are created using matlab buid-in class imroi.

addRoiToolbar: Add an ROI toolbar to the current figure.
addRoiToolbar(h): Add an ROI toolbar to the figure with a handle h.

Example 1:
   load mri;
   imshow(D(:,:,14));
   addRoiToolbar;
Example 2 (Multiple images):
   load mri;
   imdisp(D(:,:,1:8));
   addRoiToolbar;

Now draw some ROIs,and right click on one of them, you will see more functions in a context menu, such as:
   * change color
   * histogram
   * x-y plot
   * delete

Thanks to the "draggable" made by Francois Bouffard, you can drag around the textbox of ROI info.

imdisp is a nice tool to display multiple images in one figure, written by Oliver Woodford

see also: imroi, imrect, imellipse, imfreehand, imline.

Comments and Ratings (13)

%Edited by Muinul Islam

hcm= unique(cell2mat(hcm)); Replace this line by

hcm= unique([hcm{:}]);

arnold

arnold (view profile)

too bad it doesn't seem to work under 2014b or 2015a anymore.

arnold

arnold (view profile)

Hi, another idea: You offer XY Plot for a line but it would also make sense to offer an xy-plot for a selected rectangle... plot the cumulative sum (column-wise, i.e.). This is a feature I use most often with ImageJ, would be great to have in Matlab because there is currently no quick way to do it.

arnold

arnold (view profile)

Hi,

got some more suggestions of features you might wanna add:
==============================================
- the capability to simply copy a ROI, that'd be very useful!
- it would be great if one could save all ROIs and load them again on a different image
- create a cell or struct with all the ROIs (size, position, mean values etc.). This would be great for evaluating the ROIs with some code

thanks
arnold

isen

isen (view profile)

isen

isen (view profile)

Stunning work! really helps a lot, thank you!

Yi Sui

Yi Sui (view profile)

mercy,
Just check the help of imroi
You can get the position using
pos = getPosition(h)
where h is the handle of an imroi object.

mercy

mercy (view profile)

Thank You! I realized the solution was that i had to double click the image i was interested in before selecting the roi tool. Another question is does this function allow me to get the x and y data points of the roi. I would like to be able to have the same roi show up on another image in the same position. Thanks!

Yi Sui

Yi Sui (view profile)

mercy,
addRoiToolbar takes figure handles,
So you can use
addRoiToolbar(h)
where h is the handle of the figure you want to add the toolbar on.

Yi Sui

Yi Sui (view profile)

mercy,
please try
addRoiToolbar(gcf)

let me know if it works.

mercy

mercy (view profile)

Hello, I am trying to use this in a GUI with multiple axes. However the function only works on the most recently opened gui figure but i would like it to work on all the figures. How do i do this?
code:
% --- Executes just before image_processing_July9 is made visible.
function image_processing_July9_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to image_processing_July9 (see VARARGIN)

% Choose default command line output for image_processing_July9
handles.output = hObject;

% set(handles.plot_Bmode,'Visible','off');
set(handles.edit_gamma,'String', sprintf('%4.0f%', get(handles.gamma_slider,'Value')));
set(handles.edit_transparency,'String', sprintf('%4.0f%', get(handles.transparency_slider,'Value')));
addRoiToolbar
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes image_processing_July9 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

Yi Sui

Yi Sui (view profile)

arnold, thank you for your feedback.
I updated it to support the live update of histogram.

arnold

arnold (view profile)

Thanks, nice function!

Is there a way you could add a live update for a plot or histogram?

Updates

1.3

Add a slider to adjust the number of bins in histogram

1.2

Live update for histogram and x-y plot.
Display ROI area in ROI info textbox.
Display distance for line.
Work when there are multiple images in one figure.
Bug fixes.

1.1

bug fixes

MATLAB Release
MATLAB 7.14 (R2012a)
Acknowledgements

Inspired by: draggable, imdisp, ROIRool

Inspired: Enhanced Dicom Viewer, imstack

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video