Hi, i want to correct the non uniform background noise form the image to remove the dependency of the background.I tried the code which is attach but it does not work.Please help me
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, i want to correct the non uniform background noise form the image to remove the dependency of the background.I tried the code which is attach but it does not work.Please help me
2 commentaires
magate
le 31 Déc 2017
Have you tried doing a sliding background subtraction? I would maybe combine that with edge detection to try to not eliminate your data.
Ankit Rathore
le 9 Fév 2022
Modifié(e) : DGM
le 9 Fév 2022
Hey Zeeshan I wanted to connect to you I am working on similar project. Can you hwlp me out?
Réponses (1)
DGM
le 9 Fév 2022
Modifié(e) : DGM
le 9 Fév 2022
That looks like one of IA's demos that's been tinkered with. Since whoever messed with it has left a bunch of obvious typos in it and the OP is long gone, I'm not going to bother fixing that.
To answer the general question, there are various ways depending on the image and the goals.
A = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/168296/image.jpeg');
A = rgb2gray(A);
A = imresize(A,0.5); % not going to bother with giant images for a demo
% use grayscale bottomhat filter to estimate BG, subtract
B = imcomplement(imbothat(A,strel('disk',50)));
imshow(B)
%% use imflatfield
C = imflatfield(A,100);
imshow(C)
%% use basic blurring and division
% this is fundamentally the same as imflatfield()
sg = 100;
fk = fspecial('gaussian',[1 1]*2*ceil(3*sg-0.5)+1,sg);
Ad = im2double(A);
m = imfilter(Ad,fk,'replicate');
D = mean(m(:))*Ad./m;
imshow(D)
Once at that point, the image levels can be adjusted with imadjust() or the image can be binarized and cleaned up with basic morphological operations.
ImageAnalyst's demo and his own answer can be found here:
See also:
The lesson that nobody seems to learn from these exercises is to take every chance you can to make sure your photographic staging gives you uniform lighting and good subject-background contrast in the first place. You can either spend an hour trying to make a precarious stack of filters in an attempt to accurately and repeatably extract a white object from a white background ... or you can spend 30 seconds to use a black piece of paper instead.
1 commentaire
Image Analyst
le 16 Fév 2022
That last paragraph cannot be emphasized enough! So true!
Even if you do have uniform lighting, your lens will introduce lens shading so you still need to do background correction.
Another nice trick if you have shine, glare, or specular reflection problems is to have a polarizer in front of your lights, and another rotatable one in front of your camera lens. Rotate the polarizer on the lens to reduce or eliminate the specular reflections.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!