Professional Documents
Culture Documents
Ee553 HW8
Ee553 HW8
net/publication/334746022
CITATION READS
1 5,691
1 author:
SEE PROFILE
All content following this page was uploaded by Juan Aguirre Escudero on 29 July 2019.
INTRODUCTION
Choosing a corresponding filter on image processing could be prove valuable if we understand
what we want to see as the end result. Such is the case for our nonlinear filter class “weight
median filter” in which has two intrinsic properties: edge preservation and efficient noise
attenuation with robustness against impulsive-type noise [1]. The fact that preserves the edges
of the image helps the visual perception of the image structure while reducing the noise, but at
the same time it also creates small spots of flat intensity, that affect sharpness [2]. For the
following application we have to consider that a color image contains three planes “rgb” red,
green, and blue. Hence, we can implement the median filtering with a particular filter
window/mask “pixel-matrix size” on each of the planes and combine them together for a result
of a restored image.
THEORY
The weighted median (WM) filter was first presented as an overview of the standard median
filter, where a nonnegative integer weight is assigned to each position in the filter window [1].
Color assigned by a median filter determined by colors of the majority of neighboring pixels
within the filter region and because of this approach this filter is considered robust since single
high or low values “outliers” on the pixel intensity cannot influence our result unlike linear
average. To compute result, each pixel value within filter region is inserted W(i,j) times to create
extended pixel vector as seen on Fig.1.
On the second part of our code Fig.4, as requested in our assignment, we request the user to
input the weights by letting them define on the Command window nxm values where each output
pixel contains the median value in the m-by-n neighborhood around the corresponding pixel in
the input image. We also display the color image, while extracting each individual color plane.
Then we introduce some salt & pepper “impulse” noise with a noise density of 0.05. We have to
keep in mind individual noise at each color plane[3]. For our median filter we use the MATLAB
built function medfilt2(channel, [m n]) [4].
Fig.5 covers part-c of our code in which we find the noise at each color plane and proceed to
apply the weight median filter and bring all 3 color planes by concatenating them using the “cat”
function. In our first example we used a 3x3 nxm weight matrix.
Then I proceed to change the window of the matrix size of neighbouring pixels from 3x3 to
60x60 a bigger array “way out of a normal application scope” so we can observe some noise on
our restored Image as seen on Fig. 7. Here we start seeing that the weighted median is getting
more of the purple background in our peppers due to the bigger array.
Figure 7: Color Weight Median Filter Application Images “60X60”
CONCLUSIONS
Implementing the corresponding filter for our image processing can be interesting and useful
since we get to see the results of it. The weight median filter for our color RGB planes maintain
a good image structure since this particular filter focus on edge preservation and efficient noise
attenuation with robustness against impulsive-type noise such as the salt and pepper noise.
This filter in particular assigns weights number of “votes” to filter positions of the neighboring
pixels within the pixel region hence the importance to keep a relevant smaller array such as a
3x3 or 5x5. Image postprocessing is definitely a big part of the DSP community due to the
numerous applications we see and use around us, such as the application presented on this
paper.
REFERENCES
[1] Morales, Aldo. “Lesson 8 Assignment: Implementation of Weighted Median Filters in
Images.” www.canvas.psu, July 2019.
[2] Agu, Emmanuel. “Digital Image Processing (CS/ECE 545) Lecture 4: Filters (Part 2) & Edges
and Contours.” Https://Web.cs.wpi.edu, Worcester Polytechnic Institute,
web.cs.wpi.edu/~emmanuel/courses/cs545/S14/slides/lecture04.pdf.
[3] Lim, Jae S., Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall,
1990, pp. 469-476.
[5] Cochin, Elysi. “Adaptive Weighted Median Filter.” Adaptive Weighted Median Filter - MATLAB Answers -
MATLAB Central, MathWorks, 14 Jan. 2013, www.mathworks.com/matlabcentral/answers/58712-
adaptive-weighted-median-filter.
Appendix -A
MATLAB CODE (below in gray my coding and modifications) rest taken from web [5]
%EE553 _HW 8
%Juan Aguirre
%The following program Implements Weighted Median Filters
%for color images. While Letting the user pick the weights.
clc;
clear;
close all;
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 10;
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
% Generate a noisy image. This has salt and pepper noise independently on
% each color plane with a 0.05 intensity so the noise may be colored.
noisyRGB = imnoise(rgbImage,'salt & pepper', 0.05);
subplot(3, 3, 5);
imshow(noisyRGB);
title('Image with Salt and Pepper Noise', 'FontSize', fontSize);
% Extract the individual red, green, and blue color channels.
redChannel = noisyRGB(:, :, 1);
greenChannel = noisyRGB(:, :, 2);
blueChannel = noisyRGB(:, :, 3);