Simulating Film Grain
Simulating Film Grain
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Simulating Film Grain
see http://en.wikipedia.org/wiki/Image_noise#Film_grain
+noise gaussian
or
+noise poisson
should do it
+noise gaussian
or
+noise poisson
should do it
Re: Simulating Film Grain
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?fmw42 wrote:see http://en.wikipedia.org/wiki/Image_noise#Film_grain
+noise gaussian
or
+noise poisson
should do it
Re: Simulating Film Grain
Try -attenuate.
Re: Simulating Film Grain
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?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Simulating Film Grain
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/
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/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Simulating Film Grain
I noted the 0.125 fault for gaussian noise generation in the Bugs forum...
viewtopic.php?f=3&t=14863
viewtopic.php?f=3&t=14863
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Simulating Film Grain
Hi.
To simulate film grain try:
'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.
To simulate film grain try:
- ( +clone +level-colors GREY50 -attenuate 6 +noise Poisson -colorspace Gray ) -compose Overlay -composite
'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.
Last edited by vale on 2009-10-22T01:38:18-07:00, edited 1 time in total.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Simulating Film Grain
Using 6 only makes it worse!!!!
Their is something not right in the code.
Their is something not right in the code.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Simulating Film Grain
I should have added that the above commands are for BW. Remove the -colorspace Gray bit, for colour.
V.
V.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Simulating Film Grain
here is another approach from GIMP, see http://www.gimpguru.org/Tutorials/FilmGrain/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Simulating Film Grain
The gaussian noise has been fixed, though the 'attenuation' value meaning has changed slightly.
See viewtopic.php?f=3&t=14863
See viewtopic.php?f=3&t=14863
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Simulating Film Grain
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.
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Simulating Film Grain
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/