View License

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

» Watch video

Highlights from

4.8 | 13 ratings Rate this file 58 Downloads (last 30 days) File Size: 185 KB File ID: #27175 Version: 1.0
image thumbnail



Image Analyst (view profile)


Solves mazes using mathematical morphology - find the route through the maze.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

This demo works for "perfect mazes." A perfect maze is defined as a maze which has one and only one path from any point in the maze to any other point. This means that the maze has no inaccessible sections, no circular paths, and no open areas. A perfect maze should have only 2 walls (I believe). No searching or optimization methods (such as A* or dynamic programming) are used - only morphology and standard image processing methods. Only tested for 8 bit integer color and monochrome images.

Demo mazes are included, but you can specify your own maze image. Maze images should have dark walls on a light background. Maze may be surrounded by white, or go right out to the edge of the image and have the outer wall be the outer boundary of the image. The maze image should not include text or pictures, like arrows, animals, etc. -- it should include the maze walls only.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (16)
03 Nov 2016 siddhesh jadhav

thank you sir

28 Jun 2016 Abolfazl Najafi


thank you very very much:)

Comment only
16 Jun 2016 Celso Milne

15 Nov 2014 Umar Farooq

28 Feb 2014 Tian

Tian (view profile)

23 Feb 2014 Scott

Scott (view profile)

Well done! Thank you.

21 Dec 2013 Vishal Raveendranathan

Awesome one Sir!

20 Nov 2013 lee woon joo


14 May 2013 Iman Ansari

24 Mar 2013 Ranjan Keshav

Extraordinary.... Great work !!!!

28 May 2010 Benjamin

Love it.

10 May 2010 Image Analyst

Image Analyst (view profile)

Cris: You've obviously taken it a step further with some nice improvements to make it more robust and handle additional types of complicated mazes. Nice work!

Comment only
10 May 2010 Abdul Basit

Excellent idea of using image processing for the solution.

Comment only
27 Apr 2010 Matt Fetterman

Matt Fetterman (view profile)

Brilliant !!!

17 Apr 2010 Cris Luengo

Cris Luengo (view profile)

I've got some alternative solutions:

08 Apr 2010 Loren Shure

Reading the code is a fun way to learn some image processing! The only thing I didn't care for was the super-huge figures that were nearly full-screen and therefore hard to resize and move out of the way. The solution is so fast that seeing the 3 figures in order really adds insight.


Contact us