File Exchange

image thumbnail

Jann5s/measuretool

version 2.01 (860 KB) by

Interactive tool allowing the measurement of distances, radii, and angles in images

4.78788
34 Ratings

72 Downloads

Updated

Editor's Note: This file was selected as MATLAB Central Pick of the Week

# Measure Tool
Measure Tool is a matlab function (measuretool.m) that provides a Graphical User Interface (GUI) that is designed to aid measurements on images.

If an image contains some visible object of known length, for example, a scale bar or a ruler, then the physical size of an area as imaged by a pixel (i.e. the pixel size) can be calibrated. This tool provides tools to perform this calibration (draw a line on the ruler) and then perform measurements on the image:
- Distance: point-point distance
- Caliper: line-point perpendicular distance
- Polyline: multi-point distance
- Spline: smooth multi-point distance (Catmull-Rom interpolated)
- Circle: center and radius
- Angle: line-line intersection angle

The main motivation behind the tool is precision. This is achieved by allowing image magnification changes while measuring. This allows the user to place points precisely using the mouse. Additionally, all measurements can by edited to allow further refinement.

The GUI is reasonably self contained, all code resides in one file: measuretool.m
This file also contains the GUI help, which is available through the GUI itself. See the header of measuretool.m for more info.

The tool has been hosted on the Matlab FileExchange since November 2009, the corresponding website can be found here:
http://www.mathworks.com/matlabcentral/fileexchange/25964-image-measurement-utility. Recently, that site is linked to the GitHub repository, which can be found here: https://github.com/Jann5s/measuretool.

Please let me know (by submitting and issue on GitHub) if you find any bugs or issues, or if you have some nice ideas for improvement.

Comments and Ratings (56)

Jan Neggers

Jan Neggers (view profile)

@Valeria and @Rachel, the output was never supposed to be in the selected unit. My idea was that users that are advanced enough to use the output structure can multiply the value in pixels with the pixel size (as explained in the help). However, I consider it highly likely that I'm bad at predicting expectations. So I modified the output to have both, obj(j).val_px and obj(j).val_unit such that users can select which they prefer. Although, obj(j).points will still be given in pixels and you have to multiply yourself with the pixelsize.

I have the same issue with Valeria that the newest Beta version (on Github) outputs the wrong value (in pixels rather than desired unit i.e. mm). Thanks for this program!

longfei jiao

LiShang Lin

how can I run it in matlab 2014?

hi, great tool!!
I think (in the new version) that the outputs in A.obj.val are not saved correctly "as displayed in the text box" (I mean, they are in pixel, not in the selected unit).
Anyway, super thank you to you!

Jan Neggers

Jan Neggers (view profile)

The new version can be found here: https://github.com/Jann5s/measuretool
Warning: this version is in BETA, it needs testing. Please read my previous post for more info.

Jan Neggers

Jan Neggers (view profile)

Hello,

I saw that people are having issues with this tool in combination with newer matlab versions. Then when digging in this now 8 year old code, I felt it could use a refresh.

So, I've written a completely new version. It uses more modern definitions of graphics objects. Additionally, it has completely new click and drag code. This makes the GUI feel more intuitive (I hope), and now there is no longer a dependency on the image processing toolbox.

In general I think the GUI is much nicer now.

However, given all the code is fresh, and I only have matlab 2015a currently installed, I would really like it if one or two of you users would be willing to test-drive it before I publish it. I've tested it as much as I can, but there are over 3000 lines of code, and I'm pretty sure there are still some glaring bugs.

Please send me a message if you want to try the new version.

I will probably upload this new version in the beginning of 2018.

Greets Jan,

Michel Buck

Same here with R2016b. An update would be really nice for a really nice tool

Erkan Ozkat

Thank you, John. It is very good application and I have been using regularly. Recently, I have upgraded to Matlab 2017a and I faced with the below error message; when I run your application
%%%%%% Error Message %%%%%%%%%%%%%%%%%

Error using dir
Characters adjacent to a ** wildcard must be file separators.

Error in measuretool>FileBrowse_Callback (line 174)
filestmp = dir([filepath filesep '*' imagetypes{i}]);

Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in measuretool (line 41)
gui_mainfcn(gui_State, varargin{:});

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)measuretool('FileBrowse_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I was wondering if you could go through the application again, please,
King regards
Erkan

Very good tool, But I have several errors :
When I try to open a image this error appears :
Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in measuretool (line 41)
gui_mainfcn(gui_State, varargin{:});

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)measuretool('FileBrowse_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

James Huth

Thank you John. That worked!

John Clark

James, Ayman, there's an extra wildcard since the original author left wildcards in his imagetypes cell (line 155 of measuretool.m).
To fix, remove the wildcard in line 174 of measuretool.m so that it reads:
filestmp = dir([filepath filesep imagetypes{i}]);

James Huth

Hi - I'm having the same problem as Aymann... error when trying to open image. Tried to fix first "dir" error... couldn't. Any advice? Thank you.

Ayman Saleh

For some reason, whenever I try to upload an image, I keep getting these errors.
Error using dir
Characters adjacent to a ** wildcard must be file separators.

Error in measuretool>FileBrowse_Callback (line 174)
filestmp = dir([filepath filesep '*' imagetypes{i}]);

Error in gui_mainfcn (line 95)
feval(varargin{:});

Error in measuretool (line 41)
gui_mainfcn(gui_State, varargin{:});

Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)measuretool('FileBrowse_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating UIControl Callback
Anyone have any idea what I am doing wrong?

SL

SL (view profile)

It would be really great to get the syntax `measuretool(Img)` such that you do not need to use the file browser to find the file. I would also like to get better documentation with clear synapse and example commands in Matlab promp.

Nikolay

This is extremely useful. Only reason for 4/5 stars is that it re-plots the image and measurements every time and if you have a lot of measurements (100+), it can bog down a get a little slow.

This is a wonderful tool and very useful for my application. Is there a way to preserve a zoomed in view, rather than zooming out after each measurement? I'd like to stay zoomed in as I am making many measurements in a small area.

App is not opening perfectly in matlab 2014a. top portions of app is not visible. I cannot load files.

Great tool! It has been incredibly helpful for me and very easy to use. It is very accurate and makes measuring a large number of images in a dynamic environment very easy.

I was wondering if it is possible to have something that stores the calibration coordinates to the workspace similar to how the software stores the distance measurements.

So I am thinking there could be a structure that includes the following fields in the first row:

filename = 'name of image'
type = 'calibration'
value = 'distance between the two points'
intensity = '--'
profile = '--'
unit = 'calibration units'
x and y = 'the x or y coordinate for the calibration'

Also, another thing that I have noticed is that if one is measuring a large number of images and re-calibrates halfway through it changes all of the previous measurement values based on this re-calibration. It would be great in my opinion if this was more explicit or optional.

Thank you very much for this SOFTWARE.
I want to measure size of objects from capturing an image on a microscopy and this software has made my work complete.

Jan Klement

Excelenet for 2D measurements.

Amit Saha

Thank you very much for this great tool. This tool has made my project complete, on machine vision systems. Thank you, thank you so much.

Ilya Belevich

Hi Jan,
thank you for this great work!

I've noticed a small bug: when I delete a measurement the n-numbers of the others are not changed. As result addition of a new measurement produces two measurements with the same n-number.

Aditya

Aditya (view profile)

Really awesome stuff - great interface, great use of cross-hairs for identifying features.

An enhancement idea:
If I have engineering data traces, it would be great to do calibration in 2 directions and then automatically calculate coordinates of points from the origin.

Dushyant

Great App. Just wanted to say thanks!

jan

I would suggest an application for google glass of this tools.

Lacey

Lacey (view profile)

Hi Jan-

Great tool! I noticed the measurement displays with only two decimal places. Can you build in an option that allows you to select how many significant digits you wish to display the measurement? Also, is it possible to make an option to display the x and y coordinates of the distance as well?

Thanks for posting this app. It is very helpful!

Jan Neggers

Jan Neggers (view profile)

Thank you Jie, you are correct, I forgot to add .bmp to the list of options, and your fix is perfect. I will update the tool accordingly.

Jie

Jie (view profile)

I think this is a great tool.
But I have a doubt. Does this toolbox work for .bmp file? When I try to browse .bmp files, there seems to be error. Pictures I took in microscope is usually .bmp file.
I simply add "*.bmp"(in correct form) in your .m file No. 156 & 160 line. It seems work good. Do you think I'm doing right? Wish to hear from you.

Justin Blaber

Justin Blaber (view profile)

Thanks for the great tool!

Matt

Matt (view profile)

Great tool, easy to use and works well. The ability to turn off image processing tool box requirement is a very nice touch

Justin

Justin (view profile)

I haven't used this much yet, but it looks great. Is there any simple way to reduce the height of the GUI so that it doesn't extend below my task bar though?

Mario

Mario (view profile)

It is very simple and its use is intuitive. I love it and use it all the time.

Ahmed

Ahmed (view profile)

ganzong

This is really a good work. Well done.

Great job

Vijay

Vijay (view profile)

How to get the real length & breadth of an image in millimeters?
i need it to calculate pixels/mm for my text extraction project

Shahab

Shahab (view profile)

great program, thanks

Sabad

Sabad (view profile)

Amazing tool!
So useful. Thanks a lot.

Civil Eng

I am getting errors whatever I click

Civil Eng

Selcuk Fidan

ling li

wonderful

Jan Neggers

Jan Neggers (view profile)

Hi Jakub, i'll see what I can do, this is a little bit more complex as one might think since the intensity is stored in pixels which are discrete by nature, and the measurement lines do not follow pixel locations per se, so some interpolation is required.

Jakub

Jakub (view profile)

Hi Jan,

Great tool. Would it be possible to add a feature to measure mean intensity of signal within line length.

cheers
jakub

superb tool ..Thank u

Jan Neggers

Jan Neggers (view profile)

@Becky

If you don't have the function imline, then you probably have a matlab version older then 2009b, or maybe the function is provided by the image processing toolbox.

Becky

Becky (view profile)

I am getting an error when I try to calibrate (see below). Can you offer any suggestions? I have an jpeg radiographic image.

??? Undefined function or method 'imline' for input arguments of type 'double'.

Error in ==> measuretool>Calibrate_Callback at 435
h = imline(Data.gca,[u(1) v(1) ; u(2) v(2)]);

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> measuretool at 41
gui_mainfcn(gui_State, varargin{:});

Error in ==> @(hObject,eventdata)measuretool('Calibrate_Callback',hObject,eventdata,guidata(hObject))


??? Error while evaluating uicontrol Callback

great program in analyzing TEM images. I wanted to know how difficult is it to save the data because I would like to do size distribution analysis on the saved data.

Till

Till (view profile)

Hi Jan,
thanks for this nice tool. However, I have a question: I have gray scale TEM images in tif format. Your tool seems to convert them to RGB. I had a very short glance at the code, and think it is related to the call of imagesc in line 324. It might also be related to the specific format of my tif file. It would be nice, if you could comment on this.

this GUI is excellent. It can measure the distance between 2 points, perpendicular distance of a point from a line, angle between 2 lines. This GUI is fantastic.

Jan Neggers

Jan Neggers (view profile)

I've posted an update to fix some minor bugs, awaiting review at the moment.

Updates

2.01

Complete rewrite, now with new code to handle mouse interactions alleviating the requirement on the image processing toolbox and (hopefully) making the tool more intuitive.

1.9

added the .bmp image type as suggested by Jie

1.8

Updated to include an App file for R2012b

1.7

Added a feature, as suggested by Jakub, now the average intensity can be drawn, and the intensity profiles can be saved to the workspace.

1.6

Made the GUI more intuative by improving the status texts, and disabling most buttons during a measurement.

1.4

A major update of the GUI, the interface is more intuitive now, also, some options have been added to allow the use of this tool for pre 2009b versions of matlab or in absense of the IP toolbox.

1.3

Added the long awaited save options, and fixed a bug with the help function not working.

1.2

I've fixed the color issue, mentioned by Till, also added a lot of comments to make the code more readable, and changed the method of providing the in GUI help.

1.1

Fixed some minor bugs, that would throw errors to the command screen when pressing buttons in an unexpected order.

MATLAB Release
MATLAB 8.5 (R2015a)

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

» Watch video

Win prizes and improve your MATLAB skills

Play today