[cairo] Adding Noise To A Picture
Lawrence D'Oliveiro
ldo at geek-central.gen.nz
Tue Nov 17 20:59:34 PST 2015
On Sat, 28 Mar 2015 11:27:31 +1300, I wrote:
> It’s easy enough to generate a bunch of random pixel values, to make
> an image of pure noise. Adding noice to an existing image is another
> matter. Ideally what you want is exclusive-or operation between the
> bits of the noise pixels and the image pixels.
I figured out the right way to do this: fill a pattern surface with the
full-strength noise, then mask that into the destination image (using
cairo_mask or cairo_mask_surface) with the alpha channel of the mask
controlling the relative proportion of the noise, from 0 for a
noise-free image to 1 for total noise.
> The script is here
> <https://github.com/ldo/qahirah_examples/blob/master/noisy_picture>,
> and you can see the output here
> <http://default-cube.deviantart.com/art/Noisy-Picture-520465768>.
Both updated.
More information about the cairo
mailing list