Pages: 1 ... 17 18 [19] 20 21 ... 24   Go Down

Author Topic: A free high quality resampling tool for ImageMagick users  (Read 240584 times)

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #360 on: October 02, 2014, 08:19:02 am »

...
After my initial investment in time, I tried to avoid changing too many things too fast. I preferred waiting for some user feedback, likes, dislikes, the dust to settle as it were. It's just a case of not trying to aim at a moving target until it slows down enough, to take a shot, and then aim at the next target.
...
Ah OK. I get it: I'm impatient. That's what I was missing.
Logged

JRSmit

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 922
    • Jan R. Smit Fine Art Printing Specialist
Re: A free high quality resampling tool for ImageMagick users
« Reply #361 on: October 02, 2014, 09:38:11 am »

(I reserve my opinion w.r.t. upsampling. Different game.)
Would like to see this "game" further pushed forward. Can act as tester, my focus is on cases where large prints are needed, thus need to uprez images.
Logged
Fine art photography: janrsmit.com
Fine Art Printing Specialist: www.fineartprintingspecialist.nl


Jan R. Smit

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8913
Re: A free high quality resampling tool for ImageMagick users
« Reply #362 on: October 02, 2014, 11:50:28 am »

Would like to see this "game" further pushed forward. Can act as tester, my focus is on cases where large prints are needed, thus need to uprez images.

Hi Jan,

As it is, the upsampling routines attempt to 'do (very) well' (in avoiding nasty/distracting artifacts in final output, yet remaining relatively sharp in image detail without 'jaggies') on a variety of subject matter (see some examples here). Of course, it would probably be possible to tweak a bit more for specific image content, so feel free to suggest (provide a small crop of something that you hope can be done better than your current workflow offers) what to consider.

And as always, the better the input image is (i.e. not over-sharpened), the better the output will be. Otherwise we will only enlarge the artifacts that were already there, accurately...

Also consider that there may be alternative, more involved, applications that can do a bit better e.g. because they use more advanced (iterative) post-processing after resizing. In such cases the output from this script could perhaps serve as input for such an application. Lightroom for example does a decent job, but offers IMHO not enough control. It also looks a lot like some sort of bilinear resampling is used for enlarged output of edge detail, which produces less vivid results than a more edge contrast preserving method.

As mentioned before, you can also experiment with deconvolution sharpening by initially selecting a '0' amount of sharpening, which will then prompt a question to add deconvolution sharpening after the the actual resizing took place (you can at that time already copy the resized and saved file without sharpening from your computer, before it gets reloaded and replaced by the deconvolved version when the script continues). You could try out some different values, but a 'blur size' equal to the enlargement factor (e.g. 4 pixels for a 400% enlargement) is a reasonable starting point. If halos start to become visible when you boost the amount, then a smaller blur size may work better. This is only basic single pass deconvolution, but it's more tweakable than a few baked-in presets.

Cheers,
Bart
« Last Edit: October 02, 2014, 11:53:16 am by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #363 on: October 05, 2014, 06:39:15 am »

You can't achieve with ImageMagick what I'm attaching here (actually, you need a program that currently only exists on my laptop's HDD), but if you have opinions RE: the following results, I'd be thankful to have the opportunity to read them.
Perfect examples of theory lining up with results. Things are not always this "perfect".
(Obviously (?), I'm not going for halo free. I'm going for good clean punch.)
P.S. Very thankful to Bart van der Wolf, Jim Kasson, Alan Gibson and Fred Weinhaus for inspiring code and ideas. And of course Anthony Thyssen for introducing me to EWA (Elliptical Weighted Averaging) a few years back, as well as suggesting that Mitchell-Netravali would be a good EWA weight function (and to Cristy et al for providing all of us with ImageMagick and, most importantly, its source code).
« Last Edit: October 05, 2014, 06:53:10 am by NicolasRobidoux »
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #364 on: October 05, 2014, 07:30:39 am »

Here are versions with a softer recipe derived with the same theory.
« Last Edit: October 05, 2014, 08:01:27 am by NicolasRobidoux »
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8913
Re: A free high quality resampling tool for ImageMagick users
« Reply #365 on: October 05, 2014, 08:57:24 am »

You can't achieve with ImageMagick what I'm attaching here (actually, you need a program that currently only exists on my laptop's HDD), but if you have opinions RE: the following results, I'd be thankful to have the opportunity to read them.
Perfect examples of theory lining up with results. Things are not always this "perfect".
(Obviously (?), I'm not going for halo free. I'm going for good clean punch.)

Hi Nicolas,

Quite a nice balance between trade-offs for this image. While the higher spatial frequencies (and aliasing) have a higher (esp. undershoot) amplitude, they do mix into a pleasant rendering for this image at this size. I assume that the higher aliasing amplitude is less than the increased amplitude of the highest spatial frequencies that those aliases will be mirrored to, so that results in a net gain.

I do indeed wonder how it does on the slanted edge target (which will show how well it is usable for various subjects, and it allows to quantify its resulting sharpness). Another interesting (really tough) image like this one (resized to 533x800 pixels poses some interesting challenges that made me revise some of the earlier IM attempts) would also be nice to see your version of.

Cheers,
Bart

P.S. I've been experimenting with higher Keys Cubic alpha values in ImageMagick, but the gains are minimal and the drawbacks need more elaborate artifact suppression than we have currently implemented (so that may be the next thing I'll concentrate on). Especially the dark side halo undershoot becomes problematic pretty fast, and raising the gamma above 5 will start to visibly affect color saturation (of single pixels), in the 32-bit IM version.

P.P.S. Here's a link to another (star) test-target that will reveal aliasing issues quite well, typically a challenge with down-sampling. It's also with this target that the difficulty with higher Keys alpha values is in the increased tendency to produce visible aliasing and other resampling artifacts. Of course, this is a more critical challenge than normal subject matter will pose, but that's the purpose (reveal worst case scenario performance).
Attached is what the current script (Version 1.2.2) produces when down-sampled to 20%, with a sharpening amount of 100.

The Nyquist frequency is as always located at a central diameter of 92 pixels, regardless of down-sampling percentage. Inside that diameter we can expect aliasing that would show up as aliasing mixed with small features in regular patterned image content, and just outside that diameter there may be visual artifacts due to resampling issues (blocking, ringing, quantization).
Make sure to watch at 100% zoom in a dedicated image editor/viewer, the browser may still resize it despite what it tells you.
« Last Edit: October 06, 2014, 06:02:18 am by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #366 on: October 05, 2014, 09:22:49 am »

...
While the higher spatial frequencies (and aliasing) have a higher (esp. undershoot) amplitude
...
Bart:
I was thinking about exactly that after posting the prototype's results.
Question: What size would you like to see the slanted edge resized to (widthxheight in pixels)? (Note that I am not tackling upsampling head on right now.)
What's the gamma you used to produce it? Straight gamma or linear then sRGB conversion?
Logged

alain

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 465
Re: A free high quality resampling tool for ImageMagick users
« Reply #367 on: October 05, 2014, 11:16:38 am »

You can't achieve with ImageMagick what I'm attaching here (actually, you need a program that currently only exists on my laptop's HDD), but if you have opinions RE: the following results, I'd be thankful to have the opportunity to read them.
...

When looking at them (2:1 and 1:1) I like the softer look for the eye's and and the "other" look for the rest of the image.
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8913
Re: A free high quality resampling tool for ImageMagick users
« Reply #368 on: October 05, 2014, 11:29:51 am »

Bart:
I was thinking about exactly that after posting the prototype's results.
Question: What size would you like to see the slanted edge resized to (widthxheight in pixels)? (Note that I am not tackling upsampling head on right now.)

A 25% of the original should be fine. That would produce 200x75 pixels, which is fine in PNG or TIFF, but not ideal for JPEG (which prefers modulo 8 or 16 pixels dimensions, thus 24% would be preferable for that).

Quote
What's the gamma you used to produce it? Straight gamma or linear then sRGB conversion?

The source was linear gamma, but an Adobe RGB profile was assigned/embedded.

Cheers,
Bart
Logged
== If you do what you did, you'll get what you got. ==

JRSmit

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 922
    • Jan R. Smit Fine Art Printing Specialist
Re: A free high quality resampling tool for ImageMagick users
« Reply #369 on: October 06, 2014, 02:30:36 am »

Hi Jan,

As it is, the upsampling routines attempt to 'do (very) well' (in avoiding nasty/distracting artifacts in final output, yet remaining relatively sharp in image detail without 'jaggies') on a variety of subject matter (see some examples here). Of course, it would probably be possible to tweak a bit more for specific image content, so feel free to suggest (provide a small crop of something that you hope can be done better than your current workflow offers) what to consider.

And as always, the better the input image is (i.e. not over-sharpened), the better the output will be. Otherwise we will only enlarge the artifacts that were already there, accurately...

Also consider that there may be alternative, more involved, applications that can do a bit better e.g. because they use more advanced (iterative) post-processing after resizing. In such cases the output from this script could perhaps serve as input for such an application. Lightroom for example does a decent job, but offers IMHO not enough control. It also looks a lot like some sort of bilinear resampling is used for enlarged output of edge detail, which produces less vivid results than a more edge contrast preserving method.

As mentioned before, you can also experiment with deconvolution sharpening by initially selecting a '0' amount of sharpening, which will then prompt a question to add deconvolution sharpening after the the actual resizing took place (you can at that time already copy the resized and saved file without sharpening from your computer, before it gets reloaded and replaced by the deconvolved version when the script continues). You could try out some different values, but a 'blur size' equal to the enlargement factor (e.g. 4 pixels for a 400% enlargement) is a reasonable starting point. If halos start to become visible when you boost the amount, then a smaller blur size may work better. This is only basic single pass deconvolution, but it's more tweakable than a few baked-in presets.

Cheers,
Bart
Coming days or so i will test both Focus Magic and Topaz Details, icm different images and different settigns of the script. Will post results.
Logged
Fine art photography: janrsmit.com
Fine Art Printing Specialist: www.fineartprintingspecialist.nl


Jan R. Smit

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #370 on: October 06, 2014, 10:30:32 am »

Coming days or so i will test both Focus Magic and Topaz Details, icm different images and different settigns of the script. Will post results.
A few suggestions:
Given that you are enlarging, stick to the "generic" scheme, with sharpening between 0 and 33 or so (up to 50 maybe?), and no added deconvolution or what not. The other schemes have other target uses.
The main possible improvement to the v122 script if you are using it for "real work" is more careful handling of other colorspaces than sRGB. Start by reading http://im.snibgo.com/resamphm.htm#colsp.
Generally, I suggest that your final image use the same color space as the input image unless you really know what you are doing (with color spaces, image formats, and ImageMagick).
Off the top of my head but important If your input image belongs to a color space that is a "pure" gamma space (which sRGB is not: it's only approximately a gamma space), I would replace the initial
-set colorspace sRGB -colorspace RGB
by
-evaluate Pow INPUT_IMAGE_GAMMA
and the final
-set colorspace RGB -colorspace sRGB
by
-gamma INPUT_IMAGE_GAMMA
in the :generic section of the bat file. This produces inefficient (and probably slightly inaccurate) code; I can indicate how to streamline things if someone cares.
P.S. In case this is not clear: INPUT_IMAGE_GAMMA is supposed to be replaced by the numerical value of the gamma of your input = output color space. For Adobe RGB, it is 2.19921875, which you would put in the .bat file before running it.
-----
I am very much looking forward to hear about the results of your tests, because even though I have focused my attention on downsampling I think LWGB has a better chance of being a winning scheme when upsampling.
« Last Edit: October 06, 2014, 01:07:24 pm by NicolasRobidoux »
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8913
Re: A free high quality resampling tool for ImageMagick users
« Reply #371 on: October 06, 2014, 11:07:33 am »

A few suggestions:
Given that you are enlarging, stick to the "generic" scheme, with sharpening between 0 and 33 or so (up to 50 maybe?), and no added deconvolution or what not. The other schemes have other target uses.
The main possible improvement to the v122 script if you are using it for "real work" is more careful handling of other colorspaces than sRGB. Start by reading http://im.snibgo.com/resamphm.htm#colsp.
Generally, I suggest that your final image use the same color space as the input image unless you really know what you are doing (with color spaces, image formats, and ImageMagick).

Given that many photographers use Lightroom as their Digital Asset Management (DAM) system and Raw converter, it is easy enough to output the file that needs to be upsampled, with the destination profile conversion already done. Then that fie has a colorspace that will undergo a relatively benign roundtrip to linear(ish) gamma space, and back to that destination colorspace.

Once the colormanagement conversions of IM are verified to be accurate enough and properly used in linearization, and the Path(s) to the relevant source and destination profiles (including a fallback if no profile is found) is encoded, we may compare the practical implications for image quality of doing the resampling in a colormanaged environment to the current simple solution. However, profile conversions can also be a minefield (because of gamut volume differences, differences in quantization step sizes, perceptual non-linearity, dithering, etc.) ...

Quote
I am very much looking forward to hear about the results of your tests, because even though I have focused my attention on downsampling I think LWGB has a better chance of being a winning scheme when upsampling.

Indeed.

Cheers,
Bart
Logged
== If you do what you did, you'll get what you got. ==

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #372 on: October 06, 2014, 11:58:08 am »

...
P.S. I've been experimenting with higher Keys Cubic alpha values in ImageMagick, but the gains are minimal and the drawbacks need more elaborate artifact suppression than we have currently implemented (so that may be the next thing I'll concentrate on). Especially the dark side halo undershoot becomes problematic pretty fast, and raising the gamma above 5 will start to visibly affect color saturation (of single pixels), in the 32-bit IM version.
...
Thank you for trying.
I'm getting pretty good results downsampling with EWA Keys (others too).
But I am also aware they have have limitations. Most pronounced when upsampling more than a little, but also in the spectral domain.
My "like" is not based on worst case scenarios.
Logged

alain

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 465
Re: A free high quality resampling tool for ImageMagick users
« Reply #373 on: October 06, 2014, 01:02:55 pm »

Given that many photographers use Lightroom as their Digital Asset Management (DAM) system and Raw converter, it is easy enough to output the file that needs to be upsampled, with the destination profile conversion already done. Then that fie has a colorspace that will undergo a relatively benign roundtrip to linear(ish) gamma space, and back to that destination colorspace.

Once the colormanagement conversions of IM are verified to be accurate enough and properly used in linearization, and the Path(s) to the relevant source and destination profiles (including a fallback if no profile is found) is encoded, we may compare the practical implications for image quality of doing the resampling in a colormanaged environment to the current simple solution. However, profile conversions can also be a minefield (because of gamut volume differences, differences in quantization step sizes, perceptual non-linearity, dithering, etc.) ...

Indeed.

Cheers,
Bart
Bart
Am I also correctly guessing that for downsampling and going from prophoto to sRGB, it's better to go to sRGB before imagemagick?

Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #374 on: October 06, 2014, 01:33:50 pm »

Bart:
Your windmill is a classic.
Results with my "secret" prototypes. "Dark haloing" appears to need work. Otherwise it looks good to me. Agree? (P.S. Staircasing :(.)
(I assume that it's OK that I reproduce downsampled versions here?)
P.S. Could someone post what recent Lightroom does?
« Last Edit: October 06, 2014, 02:31:26 pm by NicolasRobidoux »
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8913
Re: A free high quality resampling tool for ImageMagick users
« Reply #375 on: October 06, 2014, 02:15:31 pm »

Bart
Am I also correctly guessing that for downsampling and going from prophoto to sRGB, it's better to go to sRGB before imagemagick?

My guess is that it's a safer route to do it that way.

Ideally one would do the conversion to the destination space as the last step in the workflow, but in this case it would mean that we will convert a gamma 1.8 pre-compensated colorspace to not exactly linear light for the resampling/sharpening. I'm not sure how much that error will influence the results though. That's why the slanted edge would be useful to see how luminance is affected if it is first assigned with ProPhoto RGB. Color will not blend at exactly linear light either.

That's why (for the moment) first converting to the destination profile will produce fewer unknown issues.

Cheers,
Bart
Logged
== If you do what you did, you'll get what you got. ==

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #376 on: October 06, 2014, 02:34:17 pm »

My guess is that it's a safer route to do it that way.
...
+1 (if your final product is sRGB).
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8913
Re: A free high quality resampling tool for ImageMagick users
« Reply #377 on: October 06, 2014, 03:23:14 pm »

Bart:
Your windmill is a classic.

It does have a lot of interesting features (single pixel lines, slanted edges, a few dust spots, shrubs, tree branches, text, etc.) and different material structures. ImageMagick handles the aliasing risk of the bricks just fine.

Quote
Results with my "secret" prototypes. "Dark haloing" appears to need work. Otherwise it looks good to me. Agree? (P.S. Staircasing :(.)

Yes, although the dark halos do add crispness to the resulting image (as it would with all smaller gamma adjustments), and some of the halos won't be too visible at such a small size. The light halos are a bit better, but a smaller deconvolution radius would do the same. The aliasing/stairstepping is a bit much though. Trying to control the dark side halos might require high gamma values, and could result in desaturated colors.

Quote
(I assume that it's OK that I reproduce downsampled versions here?)

No problem, fair use is allowed.

Quote
P.S. Could someone post what recent Lightroom does?

If nobody else beats me to it, I'll look at that tomorrow.

Cheers,
Bart
« Last Edit: October 06, 2014, 03:26:10 pm by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #378 on: October 06, 2014, 03:29:03 pm »

Keeping things soft is a good way to stay out of trouble :|
P.S The full size original has "tasteful" sharpening applied. I wonder if this contributes. Case of "don't sharpen before resizing"? (Sounds like a cop out.)
P.S.2 It's actually pretty neat to enlarge the original and check out the demosaicking artifacts. Whatever method this is sure likes 45 degree angles.
P.S.3 Instead of producing versions with the "sharpness" parameter turned down (which of course would take care of staircasing and halos), I slapped a quick and dirty halo reduction on top of the "secret" schemes. Results attached. This, of course, is one image etc etc etc. I am nonetheless pleased. (Please burst my bubble!)
P.S I have managed to improve on "prototypeMGB", but not a lot.
« Last Edit: October 10, 2014, 10:21:14 am by NicolasRobidoux »
Logged

alain

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 465
Re: A free high quality resampling tool for ImageMagick users
« Reply #379 on: October 06, 2014, 06:38:25 pm »

+1 (if your final product is sRGB).

Thanks.

Btw. When doing things inside prophoto RGB, I assumed that I would use the correct gamma, not the sRGB one.
Logged
Pages: 1 ... 17 18 [19] 20 21 ... 24   Go Up