Code covered by the BSD License  

Highlights from
Add an ROI toolbar to your figure

4.5

4.5 | 2 ratings Rate this file 20 Downloads (last 30 days) File Size: 622 KB File ID: #41120
image thumbnail

Add an ROI toolbar to your figure

by

 

04 Apr 2013 (Updated )

This function adds an ROI toolbar to your figure.

| Watch this File

File Information
Description

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.

Acknowledgements

Roi Rool, Imdisp, and Draggable inspired this file.

This file inspired Enhanced Dicom Viewer.

Required Products Image Processing Toolbox
MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
13 Aug 2014 arnold

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.

29 Sep 2013 arnold

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

02 Sep 2013 isen  
02 Sep 2013 isen

Stunning work! really helps a lot, thank you!

16 Jul 2013 Yi Sui

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.

16 Jul 2013 mercy

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!

15 Jul 2013 Yi Sui

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.

15 Jul 2013 Yi Sui

mercy,
please try
addRoiToolbar(gcf)

let me know if it works.

15 Jul 2013 mercy

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);

11 Apr 2013 Yi Sui

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

04 Apr 2013 arnold

Thanks, nice function!

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

Updates
04 Apr 2013

bug fixes

11 Apr 2013

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.

18 Jul 2013

Add a slider to adjust the number of bins in histogram

Contact us