Pages: 1 ... 19 20 [21] 22 23 24   Go Down

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

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 798
    • Hikes -more than strolls- with my dog
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #400 on: October 28, 2014, 04:25:10 am »


To avoid comparison with Photoshop screen resampling (which might be something like bilinear or worse), it would help if you could make an image crop available of the original image at 100%, e.g. the general region around the tree where you also sampled the histogram from, something like 1500x1500 pixels in size. That would result after down-sampling to 16.7% to something like 250 pixels square, still large enough to be meaningful for (visual) inspection.

Cheers,
Bart

Hi Bart, I believe that my CS5 is set up to do bicubic for screen resizing (at least that's what I have checked in the options).

Here is a link to a 1500x1500 crop from the original.

And here is a link to the same crop downsized to 400x400 in V1.22 and CS5 Bicubic (best for smooth gradients; scale, constrain and resample checked) as layers.  The histograms above refer approximately to the square area at X=205, Y=170, W=38, H=38.

Jack
« Last Edit: October 28, 2014, 04:37:22 am by Jack Hogan »
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 798
    • Hikes -more than strolls- with my dog
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #401 on: October 28, 2014, 04:35:35 am »

Now, just to make sure that there is no confusion: You are aware that Bart's script, when used with the "D" option and sharpening set to 0, uses a method that is used at not other time (EWA with a Quadratic spline kernel)?
Among the options presented by the script, "D" with sharpening 50 or 100, or the generic scheme with sharpening 50 or 100, should be preferable, unless you really really do not want the downsampler to introduce any halo.

Yes, I am aware of that.  I originally used it with sharpening around 50 but was unhappy with the results for the reasons mentioned.  I put sharpening at 0 in this case to try to help isolate what was causing the undesired loss of local contrast and saturation: the downsizing or the sharpening.  The images in the previous post suggest that the downsizing process is the likely culprit and one possible explanation for its apparently lackluster performance compared to the benchmark could be that the algorithm goes too far in its aggregate low pass filtering.

What would you recommend as a not-secret-yet-leading-edge alternative for downsizing?

Jack
« Last Edit: October 28, 2014, 04:50:53 am by Jack Hogan »
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8915
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #402 on: October 28, 2014, 06:21:57 am »

Hi Bart, I believe that my CS5 is set up to do bicubic for screen resizing (at least that's what I have checked in the options).

Hi Jack,

Due to the (non-)proofed preview, screen grabs are hazardous so I prefer actual resampled file comparisons, which is now possible with your crop, thanks for that. The bicubic resize preference doesn't apply to screen zooms (they are always quick and dirty), but to the default that is shown with e.g. the resize menu.

Quote
Here is a link to a 1500x1500 crop from the original.

Okay, things are getting clearer now. I've attached a (screen grab noless ;) ) comparison of the original as background, and two zoomed in areas of a bicubic downsample, and a downsample with the V1.2.2 script to 250 pixels a side while using Down-sample plus Sharpening Amount=100, so all defaults.

What becomes obvious, is that the bicubic version is much darker(!) which adds saturation, and more jaggy/aliased which suggests sharpness (but actually are artifacts that may help in this case of organic chaotic detail). So it's not the V1.2.2 script version being much lighter, although it could turn out a bit lighter in some isolated places, due to linear light resampling to preserve color accuracy.

If that is not wanted, and one doesn't want to address that in a separate post-downsample adjustment, then one could do the resampling with some remaining gamma, by temporarily adding some gamma to the linear light converted image before actually resizing the image (or replace the colorspace conversion by a moderate gamma conversion). But I do not think that is wise, because it will produce inaccurate colors. The more correct way to deal with it may be to reduce highlight brightness before downsampling if one wants more saturated highlights.

As for sharpness, there is nothing wrong with the windowing and averaging of the resize filter that is used in the script. There are single pixel wide features where expected, and other features are just not as dark as in the bicubic version, which makes them seem wider. It is always possible to make the deconvolution more aggressive than it should be, by reducing the radius to 0.4 and increase the amount used as desired. One could also use a sharpening setting of 1 (or zero, which activates a different algorithm) instead of the default, and use a separate deconvolution plugin or Smart sharpening with a very small radius and a large amount which can simply be recorded in a PS-action.

Such tweaks could be added to a commercial version of a resampling option, with a sort of crispness control or other creative tweaker. I've mentioned a Blend-if adjustment layer before, this could be made to fit in that functionality.

Cheers,
Bart
« Last Edit: October 28, 2014, 08:30:50 am by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8915
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #403 on: October 28, 2014, 09:05:16 am »

I've attached a cropped animation of the original, and a bicubic downsample, and a downsample with the V1.2.2 script to 250 pixels a side while using Down-sample plus Sharpening Amount=100, so all defaults. I then upsampled the smaller versions with Nearest Neighbor to the original size.

When you look at the display at the correct angle for accurate gamma, you'll see that the Bicubic is darker and thus oversaturated, and that the Script version attempts to keep the correct color. It also shows the highlight edge of the tree trunk almost disappearing with Bicubic, and retained with the script. Also the faint tree trunks in the shaded backgound almost disappear with Bicubic and are retained (the size increase is only due to relatively brighter or less dark than Bicubic pixels, and less stair-stepping and better anti-aliasing) with the script.

IMHO the script version is closer to the original, and Bicubic is darker and more saturated. Most of that effect is due to linear light resampling, i.e. gamma related as I suspected.

Cheers,
Bart

P.S. I like the saturation, no mistake about that, but perhaps starting with a less sharpened, or slightly toned down highlight version is a better way to get that transferred to the down-sampled version.
« Last Edit: October 28, 2014, 09:25:52 am by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 798
    • Hikes -more than strolls- with my dog
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #404 on: October 28, 2014, 12:21:19 pm »

What becomes obvious, is that the bicubic version is much darker(!) which adds saturation, and more jaggy/aliased which suggests sharpness (but actually are artifacts that may help in this case of organic chaotic detail). So it's not the V1.2.2 script version being much lighter, although it could turn out a bit lighter in some isolated places, due to linear light resampling to preserve color accuracy.

Hi Bart thanks for your efforts.

I've looked at the attachments and it seems to me that what one deems to be lighter/brighter and more/less saturated become subjective very quickly.  For instance in the original vs upsized downsampled animation it looks to me that bicubic may be a touch darker than the original but that V1.22 is much brighter.  Independently of why the brightening occurs (I'll leave that in your capable hands) to me the brightening appears also quite obvious when compared to the original (before bicubic downsizing).  To make sure I was not falling pray to some sort of a perceptual trap I looked at the stats in the same high frequency saturated ROI shown earlier off the TIFFs that you downloaded (Original: X=773 Y=649 H=120 W=120; Downsampled: X=206 Y=172 H=33 W=33).  Here they are with their histograms, Original on top followed by Bicubic and by V1.22:



The original and bicubic means are virtually identical (159,61 vs 159.86), while V1.22's is substantially higher (168.31).  Now look at the standard deviations: bicubic's is 91% of the original while V1.22 is only at 78%.  That's all lost local (Michelson) contrast information.

As for sharpness, there is nothing wrong with the windowing and averaging of the resize filter that is used in the script. There are single pixel wide features where expected, and other features are just not as dark as in the bicubic version, which makes them seem wider. It is always possible to make the deconvolution more aggressive than it should be, by reducing the radius to 0.4 and increase the amount used as desired. One could also use a sharpening setting of 1 (or zero, which activates a different algorithm) instead of the default, and use a separate deconvolution plugin or Smart sharpening with a very small radius and a large amount which can simply be recorded in a PS-action.

You may very well be right, but my feeling is that this is not an issue one can solve with post-sharpening: the issue, if there is one, is imo in the downsizing process.

Hope this feedback helps make the tool better.

Jack
Logged

NicolasRobidoux

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

Jack:
I have seen and measured the "lightening of high frequency detail" when downsampling with LWGB.
My guess is that it is caused by blending a result obtained with gamma light.
Deal breaker? Not my call: One of many artifacts anyway.
« Last Edit: October 29, 2014, 07:45:20 am by NicolasRobidoux »
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 798
    • Hikes -more than strolls- with my dog
Landscaper's Motto: Don't Mess with the Tones
« Reply #406 on: October 28, 2014, 06:43:51 pm »

Jack:
I have seen and measured the "lightening of high frequency detail" when downsampling with LWGB.
My guess is that it is caused by blending a result obtained with gamma light.
Deal breaker? Not my call: One of many artifacts anyway.

Indeed, different people who work with different content may come to different conclusions as to what artifacts they are willing to compromise on.  On the other hand, and I feel that I am speaking for landscape photographers at large, after one spends some time to get the full sized image to look about right for their tastes the last thing they need a resizing algorithm to do is mess with its tones.  Compromises as far as the byproducts of downsizing are concerned (softness vs ringing etc.) are fine - but don't mess with their tones :-)

Jack
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #407 on: October 29, 2014, 11:48:45 am »

...
What would you recommend as a not-secret-yet-leading-edge alternative for downsizing?
http://www.luminous-landscape.com/forum/index.php?topic=91754.msg770017#msg770017
A quick and dirty way to get something more or less like it is to replace "Quadratic" by "CatRom" in Bart's script, and use the "D" option with sharpening set to 0.
If you find it too sharp, try replacing "Quadratic" by "RobidouxSharp".
In between, you'll have to use the "-define filter:C=..." approach. CatRom is .5; RobidouxSharp is 0.3689927438004929 = (42*sqrt(2)-7)/142.
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 798
    • Hikes -more than strolls- with my dog
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #408 on: October 30, 2014, 05:52:13 am »

http://www.luminous-landscape.com/forum/index.php?topic=91754.msg770017#msg770017
A quick and dirty way to get something more or less like it is to replace "Quadratic" by "CatRom" in Bart's script, and use the "D" option with sharpening set to 0.
If you find it too sharp, try replacing "Quadratic" by "RobidouxSharp".
In between, you'll have to use the "-define filter:C=..." approach. CatRom is .5; RobidouxSharp is 0.3689927438004929 = (42*sqrt(2)-7)/142.

Excellent, will try that, thanks.
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #409 on: December 05, 2014, 07:51:40 am »

Excellent, will try that, thanks.
Jack: Have you found one of these options not to lighten high frequency areas?
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 798
    • Hikes -more than strolls- with my dog
Re: V1.22: Too Much Michelson Contrast Lost in the Transfer
« Reply #410 on: December 07, 2014, 04:28:36 am »

Jack: Have you found one of these options not to lighten high frequency areas?

Hi Nicolas,

To tell you the truth when I went back and tried to find where to apply the parameters you kindly provided I realized that I do not know/understand Imagemagick enough to roll my own command blend - so I temporarily reverted back to bicubic thinking I would come back to the issue in the future when I have more time to dedicate to it.  This hasn't happened yet :-)  Happy to test out other folks' suggestions though.

Jack
Logged

Dogway

  • Newbie
  • *
  • Offline Offline
  • Posts: 8
Re: A free high quality resampling tool for ImageMagick users
« Reply #411 on: March 23, 2015, 05:43:44 am »

Hello Jack, I think he meant the ":nodownsharp" approach, but just replacing Quadratic with CatRom.
What I don't know is if I need to define the 'c' component or is implicit in CatRom.

convert ( -quiet "%~1" -type TrueColor -write "%~dp1IMsource.icc" -depth 16 -set colorspace sRGB -colorspace RGB ^
 -filter CatRom -distort Resize %mSize% ) ^
 -set colorspace RGB -colorspace sRGB ^
 -quality 100 -sampling-factor 4:4:4 ^
 -profile "%~dp1IMsource.icc" -compress Lossless "%~dpn1_%mSize%%~x1"

I also observed something interesting in the landscape sample. If you average spatially all the pixels on the three of them (original, bicubic and Bart's script), you can see that the bicubic downscale is almost identical to original in saturation and brightness, whereas the script's downscale has less saturation and more brightness (in HSL numbers). Probably this is not relevant but enforces Jack observations on previous posts.

On Bart's post above it's easy to see that linear downscaling holds more tonal resemblance to original, at least perceptually on a 1:1 scale comparison, but I think the problem might come from the stance of giving more bias to highlights than what our non-linear brains would in real life, either from distancing from the real thing or a reproduction of it in a display or photo. Just thinking out loud.

After this insight I wanted to ask if it's possible to do image resizing in bicubic spline, if I'm not mistaken, something similar to avisynth's spline36, which I measured and to my surprise is ~99% identical to Photoshop's bicubic (avisynth applies an internal AA or so it seems). I find it a pleasant basic downscaler, with room for a slight post-sharpening in occasions.
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #412 on: March 23, 2015, 06:35:25 am »

If you specify any of Spline, Hermite, Mitchell, RobidouxSoft, Robidoux, RobidouxSharp or CatRom, you don't need to set c. It's done for you based (roughly: internal values have more precision) on the values shown in http://www.imagemagick.org/Usage/filter/#cubic_bc. They are all BC-cubic splines. -filter Cubic combined with a b or c value gives a Keys cubic. Hermite is not a Keys cubic, so you need to set both b and c if you don't invoque it by name.
(Quadratic is not a cubic spline (!), so it does not fit the pattern.)
« Last Edit: March 23, 2015, 11:27:56 am by NicolasRobidoux »
Logged

Dogway

  • Newbie
  • *
  • Offline Offline
  • Posts: 8
Re: A free high quality resampling tool for ImageMagick users
« Reply #413 on: March 23, 2015, 06:47:42 am »

It is possible I misunderstood bicubic spline with spline polynomials. This is what I refer to, is this possible in ImageMagick? Lanczos has a bit too much ringing, and bicubic are commonly a bit too soft generally speaking.
Logged

Dogway

  • Newbie
  • *
  • Offline Offline
  • Posts: 8
Re: A free high quality resampling tool for ImageMagick users
« Reply #414 on: March 23, 2015, 07:57:07 am »

Meanwhile for those interested I attach a modification of Bart's script (only the downsample part) for processing full folder files.
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #415 on: March 23, 2015, 11:26:29 am »

It is possible I misunderstood bicubic spline with spline polynomials. This is what I refer to, is this possible in ImageMagick? Lanczos has a bit too much ringing, and bicubic are commonly a bit too soft generally speaking.
That I know, the widest spline filter you can generate easily with ImageMagick has two lobes. This being said, I don't miss the method you suggest, because I find EWA Keys filters like RobidouxSharp and CatRom and deblurred EWA Lanczoses like LanczosSharp (and LanczosSharpest, which I've not had time to implement so you can call it "by name") to be plenty sharp. There is way more to "bicubic" than the one Photoshop version.
Correction I'm actually pretty sure that the only "natural spline" you can generate easily in ImageMagick is the one named "Spline", which has only one lobe.
« Last Edit: March 23, 2015, 03:30:19 pm by NicolasRobidoux »
Logged

Dogway

  • Newbie
  • *
  • Offline Offline
  • Posts: 8
Re: A free high quality resampling tool for ImageMagick users
« Reply #416 on: March 23, 2015, 06:11:37 pm »

Thank you! Spline36 has 3 lobes, here is a graph describing its curve. It looks similar to lanczos with 3 lobes but without second ringing. Is lanczos in ImageMagick also limited to 2 lobes?

I normally use CatRom as a fallback of spline36 instead of lanczos, since I tend to prefer a bit of aliasing over ringing.
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #417 on: March 24, 2015, 04:03:26 am »

Thank you! Spline36 has 3 lobes, here is a graph describing its curve. It looks similar to lanczos with 3 lobes but without second ringing. Is lanczos in ImageMagick also limited to 2 lobes?

I normally use CatRom as a fallback of spline36 instead of lanczos, since I tend to prefer a bit of aliasing over ringing.
When you are using -filter CatRom -distort Resize you are not using the Catmull-Rom cubic the usual way. (To use it the usual way, use -filter CatRom -resize.) You are using it as a weight generator for an Elliptical Weighted Averaging filter.
In ImageMagick, you can have up to 8 lobes for the windowed Sinc (-resize) and Jinc (-distort Resize) filters. The default is 3 for -filter Lanczos (and LanczosSharp).
Have a look in http://www.imagemagick.org/Usage/resize/.
« Last Edit: March 24, 2015, 04:26:14 am by NicolasRobidoux »
Logged

Dogway

  • Newbie
  • *
  • Offline Offline
  • Posts: 8
Re: A free high quality resampling tool for ImageMagick users
« Reply #418 on: March 24, 2015, 04:51:55 am »

Thank you NicolasRobidoux. I was writting a post while you posted.

Obviously I meant avisynth's CatRom on my above post, which is seemingly a bit different than everything else since avisynth uses an internal AA as stated earlier.

I run some interesting tests, all gamma encoded using the EWA flavour.
Trying to reproduce the "ideal" avisynth spline36 which is almost 99'9% exact Photoshop's bicubic, I found that Mitchell-Netravali is very near to that.
Fancying a little more tested Rubidoux Sharp and it is even nearer, basically 98% right there the 2% being translated to a very slight and not very noticeable blurriness, which can be fine tuned further with the "c" component.

That said I think I will base my downscales in this kernel, with an option to process in linear-light if desired.

As for the other results just to say that CatRom has a very strong acutance, its result is very similar to this thread's script (in its non-linear version), I know many photographers favor this strong exaggerated look, but I prefer the mentioned Robidoux Sharp finish with room to some post sharpening if necessary. The remaining test plain spline with post sharpening is too sharp and aliased to my taste, even if tuned not to oversharpen.

I uploaded the results so you judge by yourself (sorry I forgot to upload crops):
http://compare.bakashots.me/compare.php?setId=1410&comparisonId=8735


PS: maybe I should just test but I guess -set filter:lobes won't work with -filter spline right?
Logged

NicolasRobidoux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 280
Re: A free high quality resampling tool for ImageMagick users
« Reply #419 on: March 24, 2015, 05:17:16 am »


PS: maybe I should just test but I guess -set filter:lobes won't work with -filter spline right?
No, it does not. Only (TTBOMK) with windowed Sinc and Jinc, and Lagrange (the closest thing to "arbitrary number of lobes (polynomial) splines" in ImageMagick).
Logged
Pages: 1 ... 19 20 [21] 22 23 24   Go Up