Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

(Manual) median filter

$
0
0
Hi there!

I have an assignment that i need some help with.
I have to create a function:

This function should compute the mean pixel color for all sub-images (or sub-matrices) of size p x p pixels centered around each pixel in input image X, where p = 2d + 1 and d = {0,1,2,3...} is an input argument to the function. The function should handle RGB and grayscale images, and it should contain an additional input argument that specifies one of two options as to how the border on the image is handled.

In the first option, the border pixels of Y (the pixels where you cannot compute a mean color for a full p x p sub-image in X) should be set to the original X pixel color. All other pixels in output image Y should maintain the mean pixel color found for the corresponding sub-image in X.

Example (d = 1,grayscale image):
X =
7 7 8 4 5
7 1 7 4 5
4 3 3 7 6
6 1 9 8 7
2 1 1 2 7

Y =
7 7 8 4 5
7 5 5 5 5
4 5 5 6 6
6 3 4 6 7
2 1 1 2 7

In the second option, a mean color value is computed for the border pixels in Y by adjusting the size of the corresponding sub-image p x p in X accordingly (to ensure that you do not attempt to access a matrix element that does not exist).

Example (d = 1, grayscale image):
X =
7 7 8 4 5
7 1 7 4 5
4 3 3 7 6
6 1 9 8 7
2 1 1 2 7

Y =
6 6 5 6 5
5 5 5 5 5
4 5 5 6 6
3 3 4 6 6
3 3 4 6 6


If anyone could tell me how to approach this, i would appreciate it very much!

Thanks in advance!

Viewing all articles
Browse latest Browse all 2703

Trending Articles