File Exchange

image thumbnail

MAGIC - MATLAB Generic Imaging Component

version 1.5 (550 KB) by

Tutorial GUI to demonstrate basic functionality of various controls on the GUI

14 Ratings



View License

This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. The user can optionally apply a mask (region of interest) to the image so that only the area within the mask will be analyzed. The results are optionally sent to Excel. In this demo, I do some very basic particle sizing but in use, the user would replace that simple demo code in the function AnalyzeSingleImage() with their own code. Works with Windows or Unix since paths are all forward slashes. Requires the Image Processing Toolbox to do the simple particle sizing demo, but if you delete that demo code before using it, then the IP toolbox would not be required and it would still demonstrate the basic GUI-based file processing functionality.

Comments and Ratings (18)


Thanks for sharing the tutorial. I am using R2012B, but I believe this should not be a problem (most of the code runs). However, when testing histogram I am getting an error:

About to plot histogram...
Error in function PlotRGBHistograms.
Error Message:
Undefined function 'SetImageVisibility' for input arguments of type 'struct'.

Can't find references to SetImageVisibility in Matlab's docs. This would help to understand the tutorial. Where can I find some documentation on SetImageVisibility?

Btw: this link ( has the code; is this THE version?

Hysis Shepard

thank you!

Mark Hayworth

Mark Hayworth (view profile)

bhanai, you replace that simple demo code in the function AnalyzeSingleImage() with your own code. In other words, replace the message box that says "Now is when it would be running your custom code" with whatever custom code you want it to execute instead.


how to link this code with my coding sir??


javad (view profile)

Sorry for my wrong comment :)

Deepak Kumar

ramin bba

Yogesh Babu

This is nice code!!
I used an image to find the area of the object.But in the excel file Area of the each object is shown.It would like to plot number of occurrence of same object size in graph...

Amazing work! Works just fine.... Kudos!

This is a nice code and great efforts must have been put in to get this done.
This is a good contribution to knowledge.


Mohd Hanif


Jenny (view profile)


Nitin (view profile)


Ashwini (view profile)

Changqing Xu

Great! A nice display on how to use gui to play vedio



Got rid of masking and image analysis to make it simpler for beginners.


Updated to add colorbars and renamed from magic to magic_gui to avoid conflict with built-in MATLAB magic() function.


Added vertical and horizontal scroll bars.

MATLAB Release
MATLAB 8.5 (R2015a)

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

» Watch video