View License

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

» Watch video

Highlights from
Real-time Magnifying Glass: An Interactive Animation Example

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

5.0 | 3 ratings Rate this file 3 Downloads (last 30 days) File Size: 244 KB File ID: #35441 Version: 1.0
image thumbnail

Real-time Magnifying Glass: An Interactive Animation Example


Mingjing Zhang (view profile)


A real-time mouse-following magnifying glass of several different shapes

| Watch this File

File Information

This program demonstrates how to implement a not-so-simple real time magnifying glass.

How to use:
just type:



magnifier(mask, FPS)

mask is the shape of the magnifying glass which takes one of the following values:

"circle" - unsmoothed circular window
"aacircle" - smoothed circular window (default)
"gaussian" - guassian window
other string value - rectangular window

FPS defines how many time the position of the magnifying glass should be updated per second. By default, its value is 20.


The picture used in this program was taken from the A-li comic book series drawn by Xu Han (aka "Hans").

The Chinese text on the top left corner reads:
"On the Friday morning, A-li (roughly equivalent to 'foxy' in English) hung himself on the clothes rope, in an attempt to pull his ears longer...

-It was said that he fell in love with the rabbit."

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
10 Feb 2016 David Martin

Very handy tool. A few bug fixes and improvements to pass along:

1. First, anyone trying to use this tool will receive a number of errors and warnings concerning non-integer indexing at line #127. Easy fix, just need some rounding like this:

%Line 127:
round(mag_x_cropped(1):mag_x_cropped(2)-mag_pos(1)+PreMagRadius+1),:) = ...

2. As the code is written, you cannot use it to view grayscale images. However, by making a few changes at lines 70, 73, 74, and 127, you can process grayscale images:

%Line 70:
img_hdl = imshow(img_rgb);

%Line 73:
mag_img_hdl = imshow([],'Parent',MainAxesHdl);

%Line 74:
mag_img = img_rgb(1:PreMagRadius*2+1,1:PreMagRadius*2+1);

%Line 127:
round(mag_x_cropped(1):mag_x_cropped(2)-mag_pos(1)+PreMagRadius+1)) = ...

Comment only
07 May 2013 Christian Wuerslin I love your submissions!

27 Mar 2012 Gerardo Quispe

very nice~

26 Mar 2012 Lili

Lili (view profile)


Contact us