How can I get rid of the horizontal white lines?
7 次查看(过去 30 天)
显示 更早的评论
How can I remove the horizontal white lines from an image like these without majorly editing the surroundings? Medfilt has been suggested, but it doesn't seem to be working. All code is appreciated. Thank you!
0 个评论
回答(3 个)
Image Analyst
2017-7-13
You can try Fourier filtering. The white lines, if they're periodic, will show up as spikes in the spectrum which you can then zero out and inverse transform. Example attached (with demo image, not yours).
4 个评论
Image Analyst
2017-7-14
编辑:Image Analyst
2017-7-14
It doesn't look like thresholding is a good way to get the spikes. You might try zeroing out the very small, exact area where you see spikes on the Y axis of the spectrum, if you can see them. Otherwise you'll have to try some kind of ad hoc filter in the spatial domain, like summing your image horizontally (to get the vertical profile)
verticalProfile = mean(grayImage, 2);
and looking for peaks/spikes in the vertical profile..
Eric
2017-7-14
K-Nearest Neighbor Filtering does a decent job. You can play with the parameters, but here are some quick settings I tried.
For each pixel, find the 49 nearest neighbors. Of those 49, average the 25 pixels nearest in intensity to the selected pixel. Replace the value of the selected pixel with that mean.
This can be done fairly efficiently with colfilt(). The result isn't perfect, but it's not terrible, either. I attached the result for enf.jpg.
Good luck,
Eric
1 个评论
Eric
2017-7-14
You could also try the median of the 25 pixels nearest in intensity to the selected pixel.
Neighborhood operations like this should help. The lines are 1D so looking at statistics over small, 2D regions will help beat down the noise associated with the 1D streaks.
Image Analyst
2017-7-15
You can get the vertical profile, find the peaks and then replace those lines with the median filtered version. See attached test.m file.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177434/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177435/image.png)
Not perfect, but a fairly good improvement. Spend a day tweaking it and you might even get it better.
7 个评论
Image Analyst
2017-7-24
The peaks are calculated by taking the mean across the image to get the vertical profile. Then it finds the lower boundary of that profile and subtracts that smoother curve. Any peaks will have a higher value than lines without peaks and be detected by a thresholding. Any line above the threshold is determined to be a bad line with peaks and is replaced by the median filtered line.
Other lines are not affected, only lines with peaks are affected.
Why not put some energy towards making sure the noise lines don't appear in the first place. It's often easier to prevent the problem than to fix it once it's there.
Image Analyst
2017-7-25
Have you checked PubMed, or the Image Processing Literature for papers related to breathing and heartbeat correction?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!