Page 1 of 1
Randomly remove pixels from an image
Posted: 2011-02-14T07:04:46-07:00
by drmarie
I'd like to take an image and randomly remove 75% of the pixels. Can this be done?
Re: Randomly remove pixels from an image
Posted: 2011-02-14T10:57:27-07:00
by fmw42
what do you mean by "remove"? Do you mean make them transparent?
Re: Randomly remove pixels from an image
Posted: 2011-02-14T11:12:02-07:00
by drmarie
Yes
Re: Randomly remove pixels from an image
Posted: 2011-02-14T11:19:31-07:00
by fmw42
try
convert yourimage \
\( -size 128x128 xc: +noise random -channel red -separate \
+channel -threshold 75% -transparent black \) \
-alpha off -compose copy_opacity -composite resultimage.png
The command creates a mask image of random noise in the red channel, then thresholds it so that 25% is white and 75% is black, then makes the 75% black into transparency, then puts the mask into the alpha channel of the resulting image so that 75% is transparent and 25% is the original image.