I'm truly baffled why this poorly commented, poorly coded, piece of ad hoc code is the third most downloaded in the last 30 days. It just must be self perpetuating - people see it at the top of the list and download it so it stays at the top of the list. It is so bad in too many ways to list. The author clearly doesn't know how to use the Image Processing Toolbox functions. If you want a much, much better image segmentation demo/tutorial, check out this one:
http://www.mathworks.com/matlabcentral/fileexchange/25157 (A pick of the week)
12 Nov 2009
Stitch
Stiches or averages two image files or two sound files into a single file.
Author: Mark Hayworth
Takes a long time to run and the "Progress indicators" are not good. It says 4 times that need to wait and then you are Done! but actually this is only within a loop that gets executed 4 times. Then there's more to do after that, so the messages are very deceptive. Then it doesn't even display the original image or the 4 result images despite the fact that it's not a general purpose routine that returns an image - it's a script with input and output filenames hard-coded into it. Come on, at least you could display the images for us! When I did display them (myself) the results weren't even that good, which may be more the fault of the algorithm than the programmer. And there are several misspellings and so-so documentation. Overall, it needs work if it's going to be a nice demo program (for example a way to pick your own input image, etc.).