Page 5 of 6

Re: convert - downscaling comic pages

Posted: 2014-08-26T19:25:09-07:00
by fmw42
That is very odd that it creates an edge-like result for either JPG or PNG? Perhaps there is an issue with your older IM version or older png and jpg delegates. Can you upgrade?

I ran this with no problem of that sort on IM 6.8.9.7 Q16 Mac OSX

Version: ImageMagick 6.8.9-7 Q16 x86_64 2014-08-19 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib

Portable Network Graphics (libpng 1.6.12)
Joint Photographic Experts Group JFIF format (90)

Code: Select all

convert \( bw-thin_line.jpg -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 1.666666666666666 -filter RobidouxSharp -distort Resize 750x1125 -gamma 0.6 \) \
\( -clone 0 -filter RobidouxSharp -distort Resize 750x1125 \) \
-delete 0 \
\( -clone 1 -colorspace gray -auto-level \) \
-compose over -composite \
-set colorspace RGB -colorspace sRGB -depth 8 +repage \
robidouxsharp_rgb_gamma_blend_ewa.png
Image

Code: Select all

convert \( bw-thin_line.jpg -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 1.666666666666666 -filter Catrom -distort Resize 750x1125 -gamma 0.6 \) \
\( -clone 0 -filter Catrom -distort Resize 750x1125 \) \
-delete 0 \
\( -clone 1 -colorspace gray -auto-level \) \
-compose over -composite \
-set colorspace RGB -colorspace sRGB -depth 8 +repage \
catrom_rgb_gamma_blend_ewa.png
Image

Code: Select all

convert \( bw-thin_line.jpg -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 1.666666666666666 -filter Catrom -resize 750x1125 -gamma 0.6 \) \
\( -clone 0 -filter Catrom -resize 750x1125 \) \
-delete 0 \
\( -clone 1 -colorspace gray -auto-level \) \
-compose over -composite \
-set colorspace RGB -colorspace sRGB -depth 8 +repage \
catrom_rgb_gamma_blend_non_ewa.png
Image

Code: Select all

convert \( bw-thin_line.jpg -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 1.666666666666666 -filter RobidouxSharp -resize 750x1125 -gamma 0.6 \) \
\( -clone 0 -filter RobidouxSharp -resize 750x1125 \) \
-delete 0 \
\( -clone 1 -colorspace gray -auto-level \) \
-compose over -composite \
-set colorspace RGB -colorspace sRGB -depth 8 +repage \
robidouxsharp_rgb_gamma_blend_non_ewa.png
Image

Re: convert - downscaling comic pages

Posted: 2014-08-26T20:05:08-07:00
by steve___
fmw42 wrote:That is very odd that it creates an edge-like result for either JPG or PNG? Perhaps there is an issue with your older IM version or older png and jpg delegates. Can you upgrade?
Yes, I get it with either jpg or png. Yep I can upgrade. Thanks a lot for testing.

I find catrom with ewa too sharp. I have it on my list to try Nicolas'
clone method using catrom without ewa.

Re: convert - downscaling comic pages

Posted: 2014-08-26T20:12:10-07:00
by fmw42
I added Catrom and RobidouxSharp with -resize (as opposed to -distort resize) as well just now to my earlier post.

Re: convert - downscaling comic pages

Posted: 2014-08-26T23:03:10-07:00
by NicolasRobidoux
Is it the +repage command that interacts badly with the bit depth shift? This would be a bug in IM, I think.
Do you really need it? Can you just replace it by -strip?
(As always, really quickly off the top of my head.)

Re: convert - downscaling comic pages

Posted: 2014-08-26T23:04:20-07:00
by fmw42
NicolasRobidoux wrote:Is it the +repage command that interacts badly with the bit depth shift? This would be a bug in IM, I think.
It worked fine for me in my post above with the pictures. I think it is his IM version or older delegates.

Re: convert - downscaling comic pages

Posted: 2014-08-26T23:07:24-07:00
by NicolasRobidoux
Steve:
Are you still using mozjpeg? Make sure your jpeg and png libraries are compatible with ImageMagick.
convert -verbose or -version does not necessarily give the whole story because, for example, libjpeg-turbo often installs itself (or, rather, is often installed) as if it was libjpeg (I think; not sure), which is OK because it is a careful clone. So, maybe mozjpeg does the same?

Re: convert - downscaling comic pages

Posted: 2014-08-26T23:10:01-07:00
by NicolasRobidoux
Assuming updating IM does not fix the problem: What happens if you put +repage before -depth 8?

Re: convert - downscaling comic pages

Posted: 2014-08-26T23:16:35-07:00
by NicolasRobidoux
steve___ wrote: ...
I find catrom with ewa too sharp. I have it on my list to try Nicolas'
clone method using catrom without ewa.
Very reasonable. Orthogonal CatRom is a very good orthogonal method.

Re: convert - downscaling comic pages

Posted: 2014-08-26T23:25:37-07:00
by NicolasRobidoux
You may want to test other gammas in the "complex script" than 5/3 (and 3/5). I picked that one because you liked 4/3 and because it should do less damage to dense color patterns that than much larger gamma. My hunch is that >>when downsampling a lot<< gamma 2 (and 1/2) are as far as one should go unless the chosen filter really introduces too much halo. And you (Steve) seem to be angling toward filters that produce only one halo, so halo supppression is a bit less of an issue as a result.

Re: convert - downscaling comic pages

Posted: 2014-08-27T04:57:22-07:00
by steve___
My test were before I added +repage

I do not have mozjpeg installed

Re: convert - downscaling comic pages

Posted: 2014-08-27T05:23:36-07:00
by NicolasRobidoux
Fred: Indeed, the "complex script" with RobidouxSharp -distort Resize looks quite good. Thank you.

Re: convert - downscaling comic pages

Posted: 2014-08-27T06:41:01-07:00
by NicolasRobidoux
Steve: To my eye, the result with the "complex script" and RobidouxSharp -distort Resize looks a touch too sharp. I suggest you try replacing RobidouxSharp by Mitchell or Robidoux and see what you think (think what you see?).

Re: convert - downscaling comic pages

Posted: 2014-08-27T19:20:01-07:00
by henrywho
Nic, I am not really familiar with the composite operator. Would you mind pointing me to the explanation of the "complex" command line and the rationale of the blending using an alpha mask? (I guess it is meant to thicken the black lines by picking more from the gamma-adjusted downsize.)

Re: convert - downscaling comic pages

Posted: 2014-08-27T23:11:27-07:00
by NicolasRobidoux
henrywho wrote:Nic, I am not really familiar with the composite operator. Would you mind pointing me to the explanation of the "complex" command line and the rationale of the blending using an alpha mask? (I guess it is meant to thicken the black lines by picking more from the gamma-adjusted downsize.)
In this particular case, no, because the gamma is undone at the end.
What this does is a long story. The short version is that the resize through high gamma minimizes dark halos, the resize through linear RGB minimizes light halos, and the two resize results are blended on a pixel by pixel basis based on how light the pixel is. (Lighter -> more linear light resizing; Darker -> more resizing through gamma space.) This manages to do what sigmoidization was meant to but in a much more controlled way, without significant bad side effects when upsampling, and none other than a small penalty for not doing everything in linear light when downsampling.
Some details are found here: viewtopic.php?f=22&t=25935 and the "generic" scheme (not the tuned for downsampling) discussed in http://www.luminous-landscape.com/forum ... ic=91754.0.

Re: convert - downscaling comic pages

Posted: 2014-08-28T04:05:03-07:00
by NicolasRobidoux
Looked some more the line drawing comics results, and EWA RobidouxSharp with luminance-weighted gamma blending is at once more "defined" (some combination of contrast and sharpness) and less aliased than tensor (orthogonal) CatRom with luminance-weighted gamma blending. It's a close call, but on my MacBook Pro with Retina display, the first one wins consistently. (Hopefully I'm not suffering too badly from selection bias.)
-----
Henri: The longer story is this: luminance-weighted gamma blending steepens the transition between light and dark regions (or lines) while keeping things smooth. This is why it works both as a resampling scheme and a sharpening scheme.