The quality of re-sized image is not good

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?".
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: The quality of re-sized image is not good

Post by NicolasRobidoux » 2012-09-23T10:58:07-07:00

I'm not going to test liquid rescale because I've never used it and it's kind of "special".
-----
Here is my current recommendation for your situation, which takes into account that you probably are not obsessive w.r.t. file size.

convert input -colorspace rgb -define filter:window=quadratic -define filter:lobes=3 -distort resize widthxheight! -colorspace srgb -sampling-factor 1x1 -quality 89 output

"-sampling-factor 1x1" is ignored when output is not .jpg. -quality 89 only affects visual quality when it's a .jpg. So, you can use the same command across the board, and all you have to do is put the appropriate suffix (.jpg, .gif, .png) and you'll get what you want.
The above filter should work pretty well across the board for your images.
However, I've added "linear light colorspace" commands, because you are producing thumbnails, and when reducing the size of an image you should "always" use linear light. (Pardon my Greek, but I'm not only writing for you.) Linear light generally does not hurt enlargements.
Some rather terse explanations are found here: http://www.imagemagick.org/Usage/resize/#nicolas, the current version of "Nicolas Robidoux's Recommendations".
-----
Let me know how this works out for you.
Last edited by NicolasRobidoux on 2012-09-24T09:16:37-07:00, edited 2 times in total.

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: The quality of re-sized image is not good

Post by Bonzo » 2012-09-23T11:08:43-07:00

@NicolasRobidoux
Yes it could but would probably need "building" into his version of IM as I do not belive it is in the distributions.

As has been discussed in the past when liquid rescale ( seam carving) came out there is no way in IM to indicate the areas not to effect. In Gimp as you probably know ( coincidently I have just modified an image with it just now ) you can have a mask to indicate the areas to modify or not modify.
There was talk about automaticaly finding "high energy" areas which the assumtion was these would not be touched.

I wonder if an idea would be to "strech" in some way the area from the side of the resised image to the side of the canvas?

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: The quality of re-sized image is not good

Post by Bonzo » 2012-09-23T11:11:03-07:00

To resize your images to all the different sizes it would might be a good idea to write some code be it be a script, batch file or php to loop through or write each size into the one IM command line specifing the size and output name.
The loop method would be more friendly as you could specify different option and sizes outside th IM command line which would be easier to change.

User avatar
plicatibu
Posts: 5
Joined: 2012-09-22T15:10:07-07:00
Authentication code: 67789
Location: Brazil

Re: The quality of re-sized image is not good

Post by plicatibu » 2012-09-23T17:47:35-07:00

I tried to use -liquid-rescale

See the command:

Code: Select all

convert sample.png  -liquid-rescale 160x160   sample/sample-160x160.gif
Then I got this error message:

Code: Select all

convert.exe: delegate library support not built-in `sample.png' (LQR) @ error/resize.c/LiquidRescaleImage/1889.
All images generated despite the fact that the names were the expected have the same dimension of the original image.

OK, I give up. It's too much work for me.

I will study Scheme language to call Gimp.

Thank you all for the efforts.

Best regards.

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

Re: The quality of re-sized image is not good

Post by fmw42 » 2012-09-23T18:10:54-07:00

I do not believe that liquid-rescale is an option in IM for Windows. I think it is only available for Unix systems.

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

Re: The quality of re-sized image is not good

Post by fmw42 » 2012-09-23T18:56:08-07:00

Just out of curiosity, I ran all the following tests without regard to colorspace or sigmoidization. Simply to see which was the sharpest without regard to other artifacts.

Image are at: http://www.fmwconcepts.com/misc_tests/r ... rchive.zip

convert wargame.png -filter catrom -distort resize 640x480! wargame_catrom_dresize.png

convert wargame.png -filter lagrange -distort resize 640x480! wargame_lagrange_dresize.png

convert wargame.png -filter catrom -resize 640x480! wargame_catrom_resize.png

convert wargame.png -filter lagrange -resize 640x480! wargame_lagrange_resize.png

convert wargame.png -filter LanczosSharp -distort resize 640x480! wargame_lanczossharp_dresize.png

convert wargame.png -filter Lanczos -define filter:blur=.9264075766146068 -distort resize 640x480! wargame_lanczosrad3_dresize.png

convert wargame.png -define filter:window=Jinc -define filter:lobes=3 -define filter:window=Jinc -define filter:lobes=3 -resize 640x480! wargame_ginseng3_resize.png

convert wargame.png -define filter:window=Jinc -define filter:lobes=3 -define filter:window=Jinc -define filter:lobes=3 -distort resize 640x480! wargame_ginseng3_dresize.png


The first two were clearly sharper than the rest with a very slight edge to the catrom over the lagrange (both -distort resize).

All the rest were very similar in terms of sharpness.

It is interesting that -distort resize was better than -resize in the catrom and lagrange test, though I am not sure if the -distort resize is actually sharper or has some slight increase in contrast.

Both of these were slightly sharper than what he got from GIMP. All the others were on par with what he got from GIMP.

All done on IM 6.7.9.7 Q16 Mac OSX Snow Leopard (No HDRI)
Last edited by fmw42 on 2012-09-24T10:06:11-07:00, edited 1 time in total.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: The quality of re-sized image is not good

Post by NicolasRobidoux » 2012-09-23T21:48:00-07:00

@Fred:
Replace 640x480! by 500% and hopefully you'll see why I don't recommend EWA CatRom and Lagrange.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: The quality of re-sized image is not good

Post by NicolasRobidoux » 2012-09-23T22:10:31-07:00

@Fred:
This being said, I realize that they may be attractive if you want to sharpen the image.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: The quality of re-sized image is not good

Post by anthony » 2012-09-23T23:11:43-07:00

NicolasRobidoux wrote:I'm not going to test liquid rescale because I've never used it and it's kind of "special".
yes it is and as it is only pixel removal and adding it can generate aliasing.

I have always wanted to get the actual pixel removal masks and try to use it to generate displacement maps and eventually blur that
mask a little to generate area resampled versions of liquid rescaling. Sort of a filtered version of it :-)

But currently the LQR API library does not seem to provide any such access to these 'internals' to play with. :-(
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: The quality of re-sized image is not good

Post by henrywho » 2012-09-24T00:36:21-07:00

The wargame picture is a line art and it is up-sized by a few pixels only (474 -> 480). I think linear EWA Lanczos3Sharpest does the job very well.

Code: Select all

convert wargame.png -colorspace RGB -define filter:filter=Jinc -define filter:window=Jinc -define filter:lobes=3 -define filter:blur=0.88549061701764 -distort resize 640x480 -alpha off +repage -colorspace sRGB -gravity center -extent 640x480 -quality 95% output.png

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: The quality of re-sized image is not good

Post by NicolasRobidoux » 2012-09-24T06:22:25-07:00

When enlarging, EWALanczos3Sharpest occasionally has bad artifacts when, for example, two almost perfectly horizontal or vertical dark lines are about three pixel away from each other on a lighter background. This most likely has to do with the first crossing being too close to the center.
This is why I do not recommended it for enlarging.
Given that it has much to commend it, Lanczos3Sharpest goes to the top of my list of "schemes to tweak". And I have some ideas.
But I'm leaving this quest aside for a while.

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: The quality of re-sized image is not good

Post by henrywho » 2012-09-25T08:06:40-07:00

NicolasRobidoux wrote:This is why I do not recommended it for enlarging.
What about EWALanczos2Sharpest? :o

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: The quality of re-sized image is not good

Post by NicolasRobidoux » 2012-09-25T08:17:33-07:00

henrywho wrote:...What about EWALanczos2Sharpest?
If you like it, I'll give it a second look. It may have slipped between the cracks. (There are lot of schemes to compare :()

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: The quality of re-sized image is not good

Post by NicolasRobidoux » 2012-09-25T08:50:18-07:00

@Henry:
When enlarging, EWA Lanczos2Sharpest is way too jaggy, and it's performance as a reconstructor is unremarkable (per Adam Turcotte's forthcoming thesis).
If you absolutely want a 2-lobe method, you're better off with a Keys cubic, RobidouxSharp, for example.
And if you want the appearance of a 2-lobe method, Quadratic-windowed Jinc 3 is much much better. Slightly softer, yes. But in my eye it's no contest.
So, "The Recommendations" stand: EWA Lanczos2Sharpest is definitely a "dead prototype" in my book. (At least for upsampling.)

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: The quality of re-sized image is not good

Post by henrywho » 2012-09-25T09:42:49-07:00

NicolasRobidoux wrote:So, "The Recommendations" stand: EWA Lanczos2Sharpest is definitely a "dead prototype" in my book. (At least for upsampling.)
I see.... :shock: same applies to for 2% upsize also?

Post Reply