Page 1 of 1

Remove Pixels/Noise

Posted: 2011-10-14T12:03:40-07:00
by jkindness
I would like to remove the small pixels/noise from the following image while keeping the gray lines in place:
http://50.57.69.199/test.html

I gave it a black background so you can see it as it only consists of a gray color for the lines and noise and the rest of the image is transparent. Is there a simple way to remove the 1x1 pixels? I tried using unsharp which did work in some cases but it would also remove my lines in other cases.

Re: Remove Pixels/Noise

Posted: 2011-10-14T12:55:00-07:00
by fmw42
Your image is not black. It has some writing on it and the stripes and dots are in the alpha channel. Be careful what viewer you are using to view your image as it may not show the alpha channel and just turn it black.

You can see this by:


convert 05c1aaa6c810afe59b262aeb0e2e68b2.png -alpha off 05c1aaa6c810afe59b262aeb0e2e68b2_aoff.png

convert 05c1aaa6c810afe59b262aeb0e2e68b2.png -alpha extract 05c1aaa6c810afe59b262aeb0e2e68b2_alpha.png


To fix it, you need to process the alpha channel with a 3x1 median filter only and then put it in place of the original alpha channel.

This does it for me.


convert 05c1aaa6c810afe59b262aeb0e2e68b2.png \
\( -clone 0 -alpha extract -statistic median 3x1 \) \
-alpha off -compose copy_opacity -composite \
05c1aaa6c810afe59b262aeb0e2e68b2_proc.png

Re: Remove Pixels/Noise

Posted: 2011-10-14T13:25:56-07:00
by jkindness
I was actually just saying that I added a black background using HTML in order for those small pixels to show up when you viewed. Anyway, I took your code I got it working. Thanks so much for your speedy help!

Re: Remove Pixels/Noise

Posted: 2011-10-14T13:28:40-07:00
by fmw42
A 3x1 rectangular shaped morphology open should also work.