How to use filter
Show older comments
Hi all,
I am new to Matlab. I need to know how to use a filter to eliminate non-uniformity in an image.
11 Comments
Ank
on 28 Aug 2014
I can help you get started.
close all;
I = imread('11.png');
I = rgb2gray(I);
H = fspecial('disk',8);
background = imopen(I,strel('disk',40) );
background = imfilter(background,H,'replicate');
I2 = I - background;
background = imopen(I2,strel('disk',50) );
background = imfilter(background,H,'replicate');
I3 = I2 - background;
I4 = imadjust(I3);
figure;imshow(I4);
Ank
on 28 Aug 2014
More hint
close all;
I = imread('11.png');
I = rgb2gray(I);
H = fspecial('disk',10);
background = imopen(I,strel('disk',77) );
background = imfilter(background,H,'replicate');
I2 = I - background;
background = imopen(I2,strel('disk',77) );
background = imfilter(background,H,'replicate');
I3 = I2 - background;
I4 = imadjust(I3);
I5 = medfilt2(I4,[30 30]);
I5 = I5-I4;
I5 = imcomplement(imadjust(I5));
figure;imshow(I5,[]);
Ank
on 28 Aug 2014
Ok i am virtually telling u the answer replace the med filter with some low pass.
close all;
I = imread('11.png');
I = rgb2gray(I);
I2 = medfilt2(I,[20 20]);
I3 = I2-I;
I3 = imcomplement(imadjust(I3));
figure;imshow(I3,[]);
Ank
on 28 Aug 2014
Yes. I has posted the first 2 just as some hints. The 3rd one is the closes to the answer. Your approach is correct but u can see from the result that median filter works better. Median filter is also a kind of low pass filter it is not linear that all. I guess after the results of the 3rd answer you need to process your image further like using local thresholding etc depends on what you want to do with it.
Ank
on 28 Aug 2014
close all;
I = imread('11.png');
I = rgb2gray(I);
h = fspecial('gaussian',20,3);
I2 = imfilter(I,h);
%I2 = medfilt2(I,[20 20]);
I3 = I2-I;
I3 = imcomplement(imadjust(I3));
figure;imshow(I3,[]);
I = imread('11.png');
I = rgb2gray(I);
I2 = medfilt2(I,[20 20]);
I3 = I2-I;
I3 = imcomplement(imadjust(I3));
I4 = bradley(I3);
I3 = bradley(I);
I3 = I3+I4;
figure;imshow(I3,[]);
where bradley is the function in http://www.mathworks.fr/matlabcentral/fileexchange/40854-bradley-local-image-thresholding
so thing something in similar lines
imcomplement is is used as i am subtracting. check the alternative i posted for color. should be the same for color if you process it on V. I guess u cannot threshold on the V there.
close all;
OI = imread('1.JPG');
OI = rgb2hsv(OI);
I = OI(:,:,3);
h = fspecial('gaussian',20,30);
I2 = imfilter(I,h);
I3 = -I2+I;
I3 = I3-min(min(I3));
OII= OI;
OII(:,:,3) = I3;
figure;imshow(hsv2rgb(OII));
I = OI(:,:,3);
I2 = medfilt2(I,[20 20]);
I3 = -I2+I;
I3 = I3-min(min(I3));
II = I3;
I4 = bradley(I3);
I3 = bradley(I);
I3 = I3+I4;
OI(:,:,3) = II;
figure;imshow(hsv2rgb(OI));
Siam
on 4 Sep 2014
Siam
on 4 Sep 2014
Siam
on 7 Sep 2014
Image Analyst
on 8 Sep 2014
Use trial and error until you get some output that you're happy with.
Accepted Answer
More Answers (1)
Spandan Tiwari
on 28 Aug 2014
0 votes
The classical homomorphic filtering might be able to help here. See the following blog post on the blog Steve on Image Processing for details.
3 Comments
Siam
on 29 Aug 2014
Image Analyst
on 29 Aug 2014
Yes, Basically it assumes that the really, really blurred version of the image is the background or illumination pattern.
Siam
on 29 Aug 2014
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!