Preprocessing using median filter and imfilter command

hi,
I have following image http://www.flickr.com/photos/95383933@N08/8876902700/ I want to do some preprocessing I did like this
if true
f=imread('brp.jpg');f=f(:,:,1);
med=medfilt2(f,'symmetric');
ed=[-1 2 -1; 0 0 0;1 -2 1];
f=im2double(f);
ed=f-imfilter(f, ed,'replicate');
Pre=ed+f;
figure, imshow(Pre)
% code
end
after doing this I can get following types of Images

 Accepted Answer

I don't see the difference between the original image and the desired output image. What is the difference? Also, I don't understand why you're taking the vertical Sobel edge filter and then subtracting it from the original? What do you expect that to produce? Are you trying to suppress edges for some reason?

4 Comments

I just Want to do some enhancement of image, but If I use histeq that enhance it too Much , I just want to lighten the Slightly, I am trying to enhance the edges not suppress, and in fact it is suppressing the Edges, in Fact it don't look so much difference in both but there is very small difference in both image, second one is little enhanced, the Text I am following is here
Text it said use this Mask
if true
ed=[-1 2 -1; 0 0 0;1 -2 1];
% code
end
then it said pass through high pass filter, I don't know how Can I pass this mask from high pass filter? I tried this Also
if true
H = padarray(2,[2 2]) - fspecial('gaussian' ,ed,2);
% code
end
You did an edge filter with the Sobel. So if you wanted to enhance the image you would add the edges, times some weighting factor, back in to the image. Of course you could do this all in one shot and not have to add if you just add 1 to the kernel
kernel = [0 0 0; 0 1 0; 0 0 0] + weightingFactor * [-1 2 -1; 0 0 0;1 -2 1];
finalImage = imfilter(originalImage, kernel)
Though that kernel just looks for horizontal edges. You might want a gradient (Laplacian) where you find edges at any angle:
kernel = [-1 -1 -1; -1 8 -1;-1 -1 -1] / 8;
finalImage = imfilter(originalImage, kernel)
This will produce edges only and is a high pass filter. If you make the middle number 9 then you're adding back in the original image and you will have a high boost filter. You can vary the numbers to get varying amounts of edges added back in, from a little to a lot. Just make sure the sum of the kernel numbers adds to 1 so that the mean gray level of the original image does not change.
but there is nothing that seems to enhance the image, can you show me your results, I am getting Same image as original one, in first case it is the there is some addtional artifacts in image but in second case same as original image, can you elaborate more
thank you
if true
med=medfilt2(f,'symmetric');
ed=[-1 2 -1; 0 0 0;1 -2 1];
Pre =f-imfilter(med, ed);
Pre=Pre+f;
% code
end
And I got enhanced Image its Bright but as much as was Previous Image

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!