Reduce noise like Photoshop

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
slogra

Reduce noise like Photoshop

Post by slogra » 2010-03-24T03:50:17-07:00

Hi, I've been searching for a program that can do resize, filtering and unsharp mask in a batch. Sound simple eh? However none of the programs that i found so far can do everything right. Photoshop has a nice filters, but lacks high quality resizing. Other programs like ifranview have a nice resize (lanczos) but missing filter options. Yet other programs lack a batch process feature.
Right, now i'm doing filtering in photoshop and resizing in ifranview, which is not convinient at all, because i have to do stuff manually and intermediate files need to be saved/read.

I haven't played with ImageMagick yet, but i believe ImageMagick has high quality resize and batch features.
However I'm not sure about the filtering. I'm looking for a very similar filter as the Reduce Noise filter in Photoshop.
I'm not sure what this filter does exactly under the hood, but i really like it. The settings i use for this filter in Photoshop are:
- Strength 10
- Preserve detail 8
Other options are set to 0 or disabled.

In the end i want to batch process lots of huge pictures to smaller thumbs suitable for the web. What i would like the batch to do is the following:
- resize to 320*240 (i would like fairly large and detailed thumbs)
- apply noise filter
- do a subtle unsharp mask
- save to png and jpg

Other features that would like (but not a must) are: median filter and (auto) levels.

Another question i have is: Why are there differences in lanczos resizing? For example Irfanview looks quite different than Faststone. I prefer Irfanview because faststone gives ringing.

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reduce noise like Photoshop

Post by snibgo » 2010-03-24T06:14:00-07:00

You can do all that in ImageMagick, including median and auto levels. I don't know how IM's noise reduction compares to Photoshop's -- I don't use PS, nor do I de-noise images.

You would have to play with IM to see what you like. For example:

Code: Select all

convert in.jpg -resize 320x240+0+0 -noise 5 -median 5 -unsharp 5 -normalize -write out.png out.jpg
You can specify the resize filter, if you want. I use the defaults, and have never experienced ringing.
snibgo's IM pages: im.snibgo.com

slogra

Re: Reduce noise like Photoshop

Post by slogra » 2010-03-24T07:02:16-07:00

Alright, thanks, i will check it out as soon as i'm home. Your command line will give me a good start.

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reduce noise like Photoshop

Post by snibgo » 2010-03-24T07:09:31-07:00

It's just an example, of course. The numbers I gave may give horrible results. Try out one option at a time, with different (probably smaller) numbers.
snibgo's IM pages: im.snibgo.com

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

Re: Reduce noise like Photoshop

Post by fmw42 » 2010-03-24T09:26:34-07:00

You may also want to check out my isonoise and statsfilt noise filters which are unix bash scripts. see link below

slogra

Re: Reduce noise like Photoshop

Post by slogra » 2010-03-24T14:00:49-07:00

So far so good. The resize and unsharp work perfectly. I've tried all different resize methods and i prefer Box for my needs. It is sharpest without ringing. The unsharp settings are exactly the same as in PS. I also played with the jpeg settings. This is what i used:

Code: Select all

convert in.jpg -filter Box -resize 320x320+0+0 -unsharp 0x1+0.25+0 -quality 86% -sampling-factor 1x1 -write out.png out.jpg
Try it, it looks awesome! imho :p. Maybe the file is a bit big for a thumb, but i don't care.

I haven't tried noise filtering yet, which will probably be a little harder to do. Fmw42, i will try your script when i have some more time to figure them out.

Thanks!

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

Re: Reduce noise like Photoshop

Post by fmw42 » 2010-03-24T14:58:07-07:00

see also IM -despeckle

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reduce noise like Photoshop

Post by snibgo » 2010-03-24T15:05:28-07:00

And -blur and -adaptive-blur. It depends on the nature of the noise, of course.
snibgo's IM pages: im.snibgo.com

slogra

Re: Reduce noise like Photoshop

Post by slogra » 2010-03-24T15:15:05-07:00

W00t, turns out that "-enhance" does almost exactly what i was looking for in a noise filter. Too bad it doesn't have any tweak option though. I would like to tone down the filtering effect a tiny bit. Oh well, i'm very happy with the current result nevertheless.

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

Re: Reduce noise like Photoshop

Post by fmw42 » 2010-03-24T15:47:13-07:00

try -despeckle, it may be a tad better than -enhance

slogra

Re: Reduce noise like Photoshop

Post by slogra » 2010-03-26T04:47:56-07:00

I tried despeckle but it does not give the result i'm looking for, it removes details that i want to keep. Enhance is close to PS, it blurs colors that are almost the same. However the effect is way to heavy.

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reduce noise like Photoshop

Post by snibgo » 2010-03-26T05:21:20-07:00

You can lessen the effect of enhance (or other filter) by making it transparent and overlaying on the original. Vary the multplier between 0 (zero effect) to 1 (full effect).

Code: Select all

convert input.jpg ( +clone -enhance -alpha on -channel alpha -evaluate multiply 0.25 ) -composite output.jpg
snibgo's IM pages: im.snibgo.com

slogra

Re: Reduce noise like Photoshop

Post by slogra » 2010-03-26T05:56:12-07:00

Yes, that might be a good idea. Another idea i had is to apply the filter before resizing.

Well, it's almost weekend so more time to mess around :).

Post Reply