Creating random noise with Magick++

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
jonotrain
Posts: 12
Joined: 2015-06-07T21:20:12-07:00
Authentication code: 6789

Creating random noise with Magick++

Post 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).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating random noise with Magick++

Post 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.
jonotrain
Posts: 12
Joined: 2015-06-07T21:20:12-07:00
Authentication code: 6789

Re: Creating random noise with Magick++

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Creating random noise with Magick++

Post 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++.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply