Question: Program 5 : Median Filter I recently attempted to create a still life photograph of some vegetables on my kitchen counter. I took fifteen pictures;
Program : Median Filter
I recently attempted to create a still life photograph of some vegetables on my kitchen counter. I took fifteen pictures; unfortunately there was a curiously lost llama that made an appearance in each photograph. This poor llama showed up in every picture and I never did get the picture of vegetables!
When I looked at the images, I realized:
If you look closely, you can see that the most of vegetable grouping is visible in each image. The llama only blocked part of the grouping, and since it was in a different position in each photo, it usually blocked a different part of the grouping each time. If I could come up with a way to determine which pixel colors are part of the vegetable grouping and the background what I want and which pixel colors are part of the llama what I don't want I could create a photo without the llama.
It turns out there is a way to do this. We can use an image processing technique called the median filter. This is a method for removing noise or a llama in this case from a set of similar images.
In the median filter, we compare individual pixels from each image. We start out by making the assumption that most of the pixels in each image at a specific coordinate x y are same color or very close in value. These are the colors we want. Sometimes, at a particular pixel in a particular image, that pixel will be part of the llama and that pixel will have a very different color from the other pixels at the same coordinate in the other images. These different colored values are the noise we are looking for and trying to remove.
In order to pick the correct color for the pixel at each x y coordinate, we can read the color value for that particular coordinate in all the images at the same time, placing them into an array. We can then sort those values, and pick the middle value, ie the median value for that list of numbers. Once we know that median value, we can write it out to our filtered image. Each pixel really contains three values: one for red, one for green, and one for blue. By using BufferedImage Java API class, we can get the RGB value as an integer.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
