convert - downscaling comic pages
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert - downscaling comic pages
On gamma, Q16 and HDRI: If the first gamma is <1, clipping will occur at the bottom (ie in the shadows).
For a modest "-gamma 3", the result is horrible with integer Q8, but also noticeable at integer Q16. Results are better at integer Q32, or HDRI at Q8, Q16 or Q32.
For a more extreme "-gamma 40", all 6 varieties show clipping, but Q32 HDRI is the clear winner.
For a modest "-gamma 3", the result is horrible with integer Q8, but also noticeable at integer Q16. Results are better at integer Q32, or HDRI at Q8, Q16 or Q32.
For a more extreme "-gamma 40", all 6 varieties show clipping, but Q32 HDRI is the clear winner.
snibgo's IM pages: im.snibgo.com
Re: convert - downscaling comic pages
Using photoshop I created a set of delta images to illustrate how much
noise was created after down-sampling. The original, down-sample and
delta images can be found here[1]. For the D2 images I upscaled the
original file to twice its size, with nearest-neighbor resampling, then
upscaled the converted images the same way so the duplicated hard pixels
show the difference with no blurring.
'EWA Ginseng-Lab' and 'Lanczos2Sharp-Lab' showed the least noise but
looked a little too sharp. The winner in the initial tests is 'EWA
Ginseng-RGB' and second is 'Lanczos-RGB'. The command used for EWA
Ginseng-RGB' was:
These are only initial tests. There are many more to do. Besides
looking at deltas, are there any other methods I can use to show the
changes caused by down-sampling?
[1] https://dev.zcomix.com/files/ds_tests.zip
noise was created after down-sampling. The original, down-sample and
delta images can be found here[1]. For the D2 images I upscaled the
original file to twice its size, with nearest-neighbor resampling, then
upscaled the converted images the same way so the duplicated hard pixels
show the difference with no blurring.
'EWA Ginseng-Lab' and 'Lanczos2Sharp-Lab' showed the least noise but
looked a little too sharp. The winner in the initial tests is 'EWA
Ginseng-RGB' and second is 'Lanczos-RGB'. The command used for EWA
Ginseng-RGB' was:
Code: Select all
$ convert infile.jpg -colorspace RGB +sigmoidal-contrast 7.5 -define filter:window=Quadratic -distort Resize 70.8% -sigmoidal-contrast 7.5 -colorspace sRGB outfile.jpg
looking at deltas, are there any other methods I can use to show the
changes caused by down-sampling?
[1] https://dev.zcomix.com/files/ds_tests.zip
Re: convert - downscaling comic pages
I am using:
Based on this, do I need to change the syntax of the code?
Code: Select all
$ convert -version
Version: ImageMagick 6.8.7-6 Q16 x86_64 2013-11-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC HDRI Modules OpenCL OpenMP
Delegates: bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps rsvg tiff webp wmf x xml zlib
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
Steve:
Your winner is actually sigmoidized EWA Quadratic-Jinc, which has been found, by me and others, to be a good method if you don't like haloing but want strong anti-aliasing.
Normally, I would not recommend sigmoidization, but black on white line drawings are perfect for it.
P.S. Chester Brown. Most excellent taste.
Your winner is actually sigmoidized EWA Quadratic-Jinc, which has been found, by me and others, to be a good method if you don't like haloing but want strong anti-aliasing.
Normally, I would not recommend sigmoidization, but black on white line drawings are perfect for it.
P.S. Chester Brown. Most excellent taste.
Last edited by NicolasRobidoux on 2014-08-01T09:43:08-07:00, edited 1 time in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
I would suggest that instead of using some numerical measure of "good" which most likely is very loosely correlated with actually looking good, you use your eyes, making lots of comparisons in scenarios similar to the ones that matter.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert - downscaling comic pages
Yes, I was only talking about image distortion. Where EWA is spatially varying. I understand that -distort uses the same methods for a circular filter, but I believe they are stationary over the images. Correct me if I am wrong?NicolasRobidoux wrote:I beg to disagree: The best resampling filters in ImageMagick are EWA methods. So, it you want the best possible results, you "need" EWA.fmw42 wrote:EWA is of no special help unless you are distorting to some drastically changed view like an extremely tilted perspective. Face-on view don't need EWA.
To resize using EWA useinstead ofCode: Select all
-distort Resize
That's it.Code: Select all
-resize
P.S. Fred: I think we misunderstood each other.
But I certainly did not intend to discourage the use of -distort resize.
This is nit-picking, but perhaps we should call it CWA (for cylindrical or more properly circular weighted average) when used in -distort resize rather than EWA.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
Fred:
Indeed, there has been some confusion having to do with the fact that when preserving aspect ratio the ellipses are circles.
Question: "Where do ellipses come from?"
Answer: "Ellipses are the offspring of generality."
Indeed, there has been some confusion having to do with the fact that when preserving aspect ratio the ellipses are circles.
Question: "Where do ellipses come from?"
Answer: "Ellipses are the offspring of generality."
Last edited by NicolasRobidoux on 2014-08-02T03:52:20-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert - downscaling comic pages
The conic sections were named and studied at least since 200 BC, when Apollonius of Perga undertook a systematic study of their properties.Question: "Where do ellipses come from?"
Answer: "Ellipses are the offspring of generality."
Looking at it the other way, circles are just a limiting case of ellipses.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
Good point Alan. I need to get it out of my head that everyone uses HDRI.snibgo wrote:On gamma, Q16 and HDRI: If the first gamma is <1, clipping will occur at the bottom (ie in the shadows).
For a modest "-gamma 3", the result is horrible with integer Q8, but also noticeable at integer Q16. Results are better at integer Q32, or HDRI at Q8, Q16 or Q32.
For a more extreme "-gamma 40", all 6 varieties show clipping, but Q32 HDRI is the clear winner.
Re: convert - downscaling comic pages
After much testing with ImageMagick 6.8.8-5 HDRI Q16 I've settled on Catrom
with a gamma setting of 1.333333333333333/.75 and no ewa. Here is the
syntax I'm using:
The files I tested with and the output from the Catrom filter is here:
https://dev.zcomix.com/files/convert-tests.zip
I also tried a quick test with graphicmagick. The filesizes are much
smaller. The b&w and solid colour images are useable but the full
colour images (ie colour-complex and colour-detailed) at "web" size are
not. I've included those images in the zip above. The syntax I used
for graphicmagick v1.3.18 was:
(adding '-colorspace sRGB' caused the output to be way off)
Let me know if I missed anything.
with a gamma setting of 1.333333333333333/.75 and no ewa. Here is the
syntax I'm using:
Code: Select all
$ convert infile[0] -quiet -colorspace RGB -gamma 1.333333333333333 -filter Catrom -resize $res -gamma .75 -colorspace sRGB +repage outfile
https://dev.zcomix.com/files/convert-tests.zip
I also tried a quick test with graphicmagick. The filesizes are much
smaller. The b&w and solid colour images are useable but the full
colour images (ie colour-complex and colour-detailed) at "web" size are
not. I've included those images in the zip above. The syntax I used
for graphicmagick v1.3.18 was:
Code: Select all
$ gm convert infile -colorspace RGB -gamma .6 -filter Catrom -resize $res -gamma 1.666666666666666 +repage outfile
Let me know if I missed anything.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
Thank you Steve.
Putting the result of your testing in my "What worked for someone" memory box.
P.S. I persist in thinking that an EWA can always be found that does better than any tensor method in a specific situation. Have you tried something likeor?
Putting the result of your testing in my "What worked for someone" memory box.
P.S. I persist in thinking that an EWA can always be found that does better than any tensor method in a specific situation. Have you tried something like
Code: Select all
convert infile[0] -quiet -colorspace RGB -gamma 1.333333333333333 -filter RobidouxSharp -distort Resize $res -gamma .75 -colorspace sRGB +repage outfile
Code: Select all
convert infile[0] -quiet -colorspace RGB -gamma 1.333333333333333 -filter CatRom -distort Resize $res -gamma .75 -colorspace sRGB +repage outfile
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
I also think that something like this may work well given what you have found to work well, esp. with color:or maybe the same with RobidouxSharp replaced by CatRom. Instead of GAMMA=5/3 and RECIPROCALOFGAMMA=3/5, you could also try other values. See http://www.luminous-landscape.com/forum ... ic=91754.0
Also, I've not addressed the issue of how best to compress for the web. This is a whole different story. I myself use highly customized calls to libjpeg-turbo after producing images that cjpeg understands. One can do much with ImageMagick, but you need to learn how JPEG compression works to get the most out of it.
Code: Select all
convert \( input.png -depth 16 -set colorspace sRGB -colorspace RGB \) \
\( -clone 0 -gamma 1.666666666666666 -filter RobidouxSharp -distort Resize $res -gamma 0.6 \) \
\( -clone 0 -filter RobidouxSharp -distort Resize $res \) \
-delete 0 \
\( -clone 1 -colorspace gray -auto-level \) \
-compose over -composite \
-set colorspace RGB -colorspace sRGB \
output.png
Also, I've not addressed the issue of how best to compress for the web. This is a whole different story. I myself use highly customized calls to libjpeg-turbo after producing images that cjpeg understands. One can do much with ImageMagick, but you need to learn how JPEG compression works to get the most out of it.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
It actually does make sense in your context that you are not undoing the gamma you are applying, although this may give very undesirable results when you are dealing with color instead of greyscale. P.S. This previous sentence flirts with nonsense as far as trustable advice goes. Unless you are dealing with greyscale etc, not being consistent in gamma and colorspace handling is flirting with disaster. But it may help with greyscale line art.steve___ wrote:After much testing with ImageMagick 6.8.8-5 HDRI Q16 I've settled on Catrom
with a gamma setting of 1.333333333333333/.75 and no ewa. Here is the
syntax I'm using:...Code: Select all
$ convert infile[0] -quiet -colorspace RGB -gamma 1.333333333333333 -filter Catrom -resize $res -gamma .75 -colorspace sRGB +repage outfile
Also note that the -colorspace command changed meaning, roughly 2 years ago, in ImageMagick. GraphicsMagick boasts a more stable (meaning frozen) interface, and so it uses the "old" meaning. I venture that it explains the differences you see.
Last edited by NicolasRobidoux on 2014-08-24T08:37:43-07:00, edited 5 times in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: convert - downscaling comic pages
Steve: I think you forgot to include the originals in your zip file? Or is the orig folder meant to be empty.