Try this:
Also, check out my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
In one app, I solve a maze using image processing.
In another I modify images to have the shape of the histogram be what is in the photo, for example in a picture of a girl on a beach, make the histogram look like the silhouette of a girl on a beach, or a picture of a car will have a histogram in the shape of a car.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1535045/image.png)