How to remove small black dots in pictures (without using the method below how many pixels to remove)
12 views (last 30 days)
Show older comments

I have an image as shown above.Due to the dirt on the CMOS, there are many small black spots in the picture.
How can I remove them without using the method of removing less than how many pixels ? I'm worried about removing small bubbles in the images.
4 Comments
Accepted Answer
Image Analyst
on 12 Apr 2022
The standard way to do this is to make a mask of the bad spots and then use a modified median filter. Here are the steps
- Take the lens off and snap a photo. Make sure the image is not over exposed (look at the histogram).
- Segment (threshold) that photo to determine where the bad spots are. You get a binary mask image.
- Use a median filter on your image to be repaired with a window twice as big as your largest bad spot.
- Replace the bad spots in the mask with the median filtered image values:
- repaired = originalImage; % Initialize
- repaired(mask) = medianFilteredImage(mask);
You take the lens off so that you can be assured that the light on the sensor is uniform and has no structure in it. This will let you correct for defects or dust on the sensor. If you also need to correct for defects in the lens, then leave the lens on and take a picture of a uniform white background, like a sheet of white paper.
See attached examples where I do this for repairing salt and pepper noise.
3 Comments
Image Analyst
on 24 Apr 2022
The median filter smooths out images, even where there is no extreme impulse noise. So a mask is used so that only the impulse noise is replaced and the pixels not in the mask and not identified as impulse noise are not changed. So the image remains the same with no blurring anywhere there is no noise. Only the noise is changed (repaired).
More Answers (0)
See Also
Categories
Find more on Image Segmentation and Analysis 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!