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 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168296/image.jpeg)
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
magate
2017년 12월 31일
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
2022년 2월 9일
편집: DGM
2022년 2월 9일
Hey Zeeshan I wanted to connect to you I am working on similar project. Can you hwlp me out?
답변 (1개)
DGM
2022년 2월 9일
편집: DGM
2022년 2월 9일
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
Image Analyst
2022년 2월 16일
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!