Page 1 of 2
Simulating Film Grain
Posted: 2009-10-11T10:42:03-07:00
by quickbrownfox
Hi all,
I've been working on a script to create old-looking Holga-style photos. I'm pretty happy with the results so far, but I think some film grain might be in order. I've spent quite a bit of time googling, but haven't found a way to add film grain with Imagemagick. Does anyone know of a good way to do this?
Thanks in advance,
Mike
Re: Simulating Film Grain
Posted: 2009-10-11T14:10:59-07:00
by fmw42
see
http://en.wikipedia.org/wiki/Image_noise#Film_grain
+noise gaussian
or
+noise poisson
should do it
Re: Simulating Film Grain
Posted: 2009-10-11T17:38:35-07:00
by quickbrownfox
Thanks for the reply. Is there a way to change the amount of noise? Both gaussian and poisson gave me an image that was way too noisy. Maybe I need to composite the result onto a copy of my original?
Re: Simulating Film Grain
Posted: 2009-10-11T17:42:56-07:00
by magick
Try -attenuate.
Re: Simulating Film Grain
Posted: 2009-10-21T09:39:19-07:00
by quickbrownfox
Thanks, but even the lowest value of attenuate that would do anything is far too noisy. Using "-attenuate 0.1249" gave me an image with no noise whatsoever while "-attenuate 0.1250" produced an image that was almost completely noise. Am I doing something wrong here?
Re: Simulating Film Grain
Posted: 2009-10-21T10:15:05-07:00
by fmw42
you can also build a noise image separate from your image, then use convert image noiseimage -compose mathematics "A,B,C,D" -composite result
you want to mix the two images as image + atten*(noiseimage - 0.5) as you want positive and negative noise relative to midgray. So I believe that means A=0, B=atten, C=1, D=-0.5*atten
see
http://www.imagemagick.org/script/comma ... hp#compose
and
http://www.imagemagick.org/Usage/compose/
Re: Simulating Film Grain
Posted: 2009-10-21T19:16:16-07:00
by anthony
I noted the 0.125 fault for gaussian noise generation in the Bugs forum...
viewtopic.php?f=3&t=14863
Re: Simulating Film Grain
Posted: 2009-10-22T00:19:58-07:00
by vale
Hi.
To simulate film grain try:
- ( +clone +level-colors GREY50 -attenuate 6 +noise Poisson -colorspace Gray ) -compose Overlay -composite
The above should be placed last in the command sequence.
'attenuate' means (in this context) 'thin out'. Consequently, the smaller the factor; the more
tenuous the result. For a simulation of film grain you need dense, closely packed grain. More noise; not spread out (attenuated) noise. This may be counter-intuitive; try the command.
(Edit: hangover caused nonsense to appear. Apologies for the original version if you saw it)
V.
Re: Simulating Film Grain
Posted: 2009-10-22T00:42:02-07:00
by anthony
Using 6 only makes it worse!!!!
Their is something not right in the code.
Re: Simulating Film Grain
Posted: 2009-10-22T01:59:18-07:00
by vale
I should have added that the above commands are for BW. Remove the -colorspace Gray bit, for colour.
V.
Re: Simulating Film Grain
Posted: 2009-10-22T14:50:28-07:00
by quickbrownfox
Thanks, Vale. I'll give this a shot.
Re: Simulating Film Grain
Posted: 2009-10-28T19:33:47-07:00
by fmw42
Re: Simulating Film Grain
Posted: 2009-10-28T22:37:47-07:00
by anthony
The gaussian noise has been fixed, though the 'attenuation' value meaning has changed slightly.
See
viewtopic.php?f=3&t=14863
Re: Simulating Film Grain
Posted: 2009-10-29T09:44:06-07:00
by fmw42
so what does the new "attenuate" mean for gaussian and other noise?
The options page says,
"Lessen (or intensify) when adding noise to an image."
but does this mean amplitude or sigma? Perhaps Anthony could make an example on his pages and explain this.
Re: Simulating Film Grain
Posted: 2009-10-29T21:52:05-07:00
by anthony
the attenuate is supposed to adjust the amount of 'error' added. this in term equates to the difference between the original value and the final value. As such the larger the attenuation the larger the 'sigma' of the error.
As for the actual meaning. I asked Magick about that in the other thread, and he wasn't very clear, saying that two sigma values are involved, though I can't see how that could be.
However looking at things for Gaussian it looks like the attenuation is roughly a percentage of the value range. which makes some sense. However this is only guess on my part. It looks like some source diving will be needed to actually find out its correctly meaning.
At least it now does not just 'go crazy' at a value of 1.25