Page 1 of 1

Creating random noise with Magick++

Posted: 2015-06-18T08:57:52-07:00
by jonotrain
I've found a lot of documentation online about using ImageMagick's command line functions to create images of random noise, but have not been able to figure out how to reproduce that in Magick++.

ImageMagick has the +noise method Random:

convert -size 100x100 xc: +noise Random random.png

I would like to be able to set a pixel to Color("random"), for example:

sought.extent(Geometry(640,416), Color("random"), CenterGravity);

To embed a smaller image in a canvas of random noise. Of course, random isn't an acceptable argument for Color, but I'm wondering if the equivalent exists? The ideal would be if it were also possible to limit the range of colors - for example only 12-bit (#000-#FFF).

Re: Creating random noise with Magick++

Posted: 2015-06-18T09:08:57-07:00
by fmw42
I know nothing about Magick++. But you could create one pixel, use the Magick++ equivalent of +noise random on the one pixel. Then overlay that one pixel onto your image at the desired location.

Re: Creating random noise with Magick++

Posted: 2015-06-18T10:28:09-07:00
by jonotrain
Thanks Loki - is there an equivalent in Magick++? The syntax for that is what I'm wondering. If anyone knows, it would be extremely helpful to my present project.

Re: Creating random noise with Magick++

Posted: 2015-06-18T12:54:20-07:00
by dlemstra
As posted in the answer to your stackoverflow question (http://stackoverflow.com/questions/3091 ... -in-magick) you can use the addNoise method of the the Image class in Magick++.