-fx in Magick++

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

Re: -fx in Magick++

Post by smajler » 2013-11-20T03:21:51-07:00

I'm trying to do as you said using composite, 50% of script is done, now i have a problem with adding noise. I've found there is function:

Code: Select all

Image.addNoise(MagickCore::NoiseType)
but i'd like to add my own noise like noise=1. Is there any function to add specified noise?

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: -fx in Magick++

Post by dlemstra » 2013-11-20T05:00:04-07:00

What do you mean by noise=1? Maybe you are better off modifying the pixels yourself. You can use the Pixels class to read/write the pixels of your image.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

Re: -fx in Magick++

Post by smajler » 2013-11-20T06:13:09-07:00

Code: Select all

noise=1
convert convolve_kernel.png -roll -64-64 -fft ( -clone 0 -crop 1x1+64+64 +repage -scale 128x128 -clone 0 -compose 

divide -composite ) -swap 0 +delete ( cameraman_convolve_2.png -fft ) ( -clone  0  -evaluate add noise -clone  2  -

compose divide -composite ) ( -clone 1,3 -compose subtract -background gray50 -flatten ) -delete 0--3 -ift 

cameraman_deconvolve_2.png
Adding noise like here to avoid dividing by 0. Yes i can add 1 to every pixel channel but it would be slow and i thought there is a function to do this.

User avatar
fmw42
Posts: 25384
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -fx in Magick++

Post by fmw42 » 2013-11-20T10:57:01-07:00

with deconvolution such as this the noise value estimate will more likely be a very small fraction such 0.0001. You need to adjust the value by factors of about 5 to 10 to find which value gives you the best results.

smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

Re: -fx in Magick++

Post by smajler » 2013-12-02T05:23:00-07:00

Can anybody tell me how to write this line in cpp?

Code: Select all

-clone 1,3 -compose subtract -background gray50 -flatten
I can to a subtract:

Code: Select all

Image img1;
Image img2;
img1.composite(img2,0,0,ModulusSubtractCompositeOp);
but how to do a rest o line:

Code: Select all

-background gray50 -flatten

Post Reply