From: ImageAnalyst on
On Mar 16, 8:35 pm, Tessa <xiao.ding...(a)gmail.com> wrote:
> Would you mind to show me how do you do that?
---------------------------------------------------------------------------------------

clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear all; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
% Read in standard MATLAB demo image.
grayImage = imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
[pixelCounts bins] = imhist(grayImage, 256);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
subplot(2, 2, 3);
bar(bins, pixelCounts);
title('Original Histogram');

smoothedHist = medfilt1(pixelCounts, 3)
subplot(2, 2, 4);
bar(bins, smoothedHist);
title('Smoothed Histogram');
msgbox('Done!');

From: Pat Finder on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <69df3a96-9f97-4938-8b7b-c1c6a8b02fea(a)e1g2000yqh.googlegroups.com>...
> On Mar 16, 8:35 pm, Tessa <xiao.ding...(a)gmail.com> wrote:
> > Would you mind to show me how do you do that?
> ---------------------------------------------------------------------------------------
> [snip]
>
> [pixelCounts bins] = imhist(grayImage, 256);
>
> [snip]
> smoothedHist = medfilt1(pixelCounts, 3)
> [etc...]

Often in signal processing a Gaussian filter is used.
Any reason why you prefer the median filter?
From: Rune Allnor on
On 19 Mar, 07:19, "Pat Finder" <pfin...(a)netacc.net> wrote:
> ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <69df3a96-9f97-4938-8b7b-c1c6a8b02...(a)e1g2000yqh.googlegroups.com>...
> > On Mar 16, 8:35 pm, Tessa <xiao.ding...(a)gmail.com> wrote:
> > > Would you mind to show me how do you do that?
> > ---------------------------------------------------------------------------­------------
> > [snip]
>
> > [pixelCounts bins] = imhist(grayImage, 256);
>
> > [snip]
> > smoothedHist = medfilt1(pixelCounts, 3)
> > [etc...]
>
> Often in signal processing a Gaussian filter is used.
> Any reason why you prefer the median filter?

Because this is not about signal processing,
but smoothing a list of non-negative integers.

Rune
From: ImageAnalyst on
Pat:
The notable feature of a median filter is that it gets rid of
impulsive noise while allowing true step changes to get through. So
for example, it could remove salt and pepper noise on a dark/light
image of a step edge without blurring out that edge. A Gaussian
filter would average together all pixels in the window (in a weighted
fashion) and blur the edge. Usually you don't want to blur your true
signal, you just want to get rid of the noise, so that's why a
Gaussian filter is not used that much. I'd say a median filter is
used more. There are other filters more sophisticated than Gaussian
filter, such as the bilateral filter (which is still sort of on the
simple side), which are more effective than the Gaussian filter and
are used in preference to the Gaussian filter (at least by those who
know about them).

When I look at a noisy histogram, I usually see the general shape of
the curve but there will often be one bin in between two others that
seems anomalously high or low compared to its neighboring bins. It
looks like impulsive, salt-and-pepper type of noise. I want to fix of
that "bad" bin without changing the true nature of the histogram
curve. So that is why I use a median filter on the histogram array.

You could also use a Gaussian filter, or box filter, to smooth the
array, but that will broaden the "humps" in the histogram more than a
median filter. Of course it all depends on the window sizes you use
for the filters. With any of the box, Gaussian, or median filters, a
larger window size will produce more smoothing/blurring of your
signal. A Gaussian filter would have to be quite broad to get bring
down a big spike bar between two lower bars and thus broaden your
features in your histogram quite a lot, whereas a small median filter
of a 3-bin width will be quite effective at fixing that bin without
broading the other "good" features. One pass with a small median
filter and you instantly and effectively knock out the noise while
keeping your "true" histogram shape.

Does that make sense now?
-ImageAnalyst
First  |  Prev  | 
Pages: 1 2
Prev: LSB steganography
Next: simulation for wimax