Sunday, August 11, 2013

Magic wand. A9, Color segmentation

I'm not sure what magic wand you're thinking of but what I'm talking about here is the tool in Photoshop. That's the first thing I think about when I read about this activity.

This time, we use a simple image recycled from an activity in 187. This is a very nice image with two solid colors standing out namely the red spectrometer on top of my green apple notebook.
this kind of recycling does not save the environment

The parametric process basically samples a certain region of interest which should more or less encompass the colors of the object of interest. We use a Gaussian distribution to determine the probability that each pixel is colored with the the region of interest. For the red spectrometer, we sample a part of it shown below and also the resulting image when the Gaussian distribution applied.
 shiny red spectrometer
severely color blind

The resulting image is white for those that are similar in color to the region of interest. The lines on the right side are part of the orange wires from the original image. This means that it also contains some red values that are similar to our region of interest. We also notice that a small part on the right side of the spectrometer is black. This is because it has a slightly different color due to lighting probably which is beyond the reach of the distribution. However, the overall result is a good reproduction of the spectrometer.

We apply the same process but this time take a good portion of the notebook as a region of interest.

animo LaSalle!

prolly what you'll see if you had x-ray vision

Personally, I think this is another good result wherein the green notebook is identified almost completely. However, it also contains a few losses such as in the right side, again prolly because of a difference in lighting. Take note that the 'Green Apple' text is also black since it is already a different shade of green not included in our region of interest.

We also applied non-parametric segmentation as a comparison. This involves mapping the histogram of the region of interest and backprojecting the image with this histogram. I think all of us would agree that the process is much more tedious than the previous method since it involves mapping in a 2d histogram, which requires a loop within a loop and backprojecting which also requires the same process. It is a headache to code and for the computer as well since loops within loops take a lot of computer resources. Let's just see if the results justify the effort.


This time, we see that it has also identified the spectrometer but also beyond that. It has also identified the red inter-reflection on the shiny notebook. The result shows that the non-parametric method has a greater tolerance for colors that are already much different from the region of interest. However, this is not the case for the green notebook.
dirty notebook
This time, it is able to identify less than the entire notebook. There are spots on the left side of the notebook that are black. The only reason I can think of to explain this result is that the 2d histogram contains bins that are too large. It is unable to differentiate closely colored objects to the point that it identifies similarly colored objects as the same. For both coding and running speed and resulting image, the parametric method wins hands down.

For me, this is one of the more interesting topics. As I've discussed in a previous post, we never really think about what goes on behind photoshop. I wouldn't be surprised if Photoshop actually uses the parametric method in its magic wand tool. Before, it was truly magical for the computer to identify similarly colored pixels but now, the secret, the Physics is out and the magic wand tool just became a little less magical.

There are few things that can be done to extend this work such as to use a smaller bin size in the 2d histogram and to try it out on more images and colors. However, I think I did what has to be done, enough for me to give myself a 9. I would like to thank Anjali for helping me understand this activity.

No comments:

Post a Comment