Trouble Removing Uneven Background Lighting from Image
19 次查看(过去 30 天)
显示 更早的评论
Hello,
As I stated I am having some trouble removing a background from an image. I have tried using imopen, imtophat, and a couple other methods, but all of them result in the same problem. The code considers my entire image as a background. For example, here is my original image.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189204/image.png)
My code to load it is pretty simple
drop=mat2gray(imread('st000.tif'));
As you can see the illumination is fairly uneven, and when I go to convert it to a bw image it cuts off the last half of the stream. When I try and use imopen to find the background this is what I get.
background = imopen(drop,strel('disk',15));
figure()
imshow(background)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189206/image.png)
If I use imtophat I get this.
I2 = imtophat(drop,strel('disk',15));
figure()
imshow(I2)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189208/image.png)
Since this image is a little dark, I tried to enhance it using
I3=imadjust(I2);
figure()
imshow(I3)
which gave me
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189211/image.png)
I can't really use this image, since it is so blurry. I have tried taking a static image with the background, subtracting that from the bw image of the original, and that sort of works.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189213/image.png)
But as you can see it removed a lot of the resolution on the image, which I think has something to do with how I actually convert it into a bw image. I think I can get a better resolution if I can find a way to make a uniform background before converting it to bw.
0 个评论
采纳的回答
Jeff E
2015-5-20
Try using imbothat instead of imtophat, with a slightly larger kernel size.
I2= imbothat(drop, strel('disk', 30));
worked for me, with the exception of some artifacts around the edge.
3 个评论
Jeff E
2015-5-21
Use a bigger kernel size. Say, 45 or so. The artifacts around the edges will be bigger, but you'll capture the larger droplets much more effectively.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!