Better resize

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Better resize

Post by mindplay »

I'm using GFLAx in ASP.

I am not happy with the image quality when resizing images to very small sizes (e.g. thumbnails) ... I've had to migrate from ServerObjects ASPImage v2.0, which unfortunately is unstable and causes server death. But the thumbnail quality was considerably better - my thumbnails with GFLAx are too blurred.

I'm guessing the Resize function uses a straightforward bicubic resampling algorithm?

I've been trying to improve upon the quality, by gradually resizing to half the size of the source image, after doing an EnhanceDetail() ... this works better, but still not nearly as good as in ASPImage, and considerably slower.

Is there any hope of seeing something like e.g. Lanczos3 interpolation implemented in the future?

see this source code ...

Lanczos3, to my knowledge, is the best non-proprietary, high-quality image resampling algorithm available - it is also one of the fastest; not considerably slower than regular bicubic interpolation. It also seems to be what high-end graphics programs use, e.g. Photoshop...
User avatar
xnview
Author of XnView
Posts: 44572
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Better resize

Post by xnview »

mindplay wrote:I'm using GFLAx in ASP.

I am not happy with the image quality when resizing images to very small sizes (e.g. thumbnails) ... I've had to migrate from ServerObjects ASPImage v2.0, which unfortunately is unstable and causes server death. But the thumbnail quality was considerably better - my thumbnails with GFLAx are too blurred.

I'm guessing the Resize function uses a straightforward bicubic resampling algorithm?

I've been trying to improve upon the quality, by gradually resizing to half the size of the source image, after doing an EnhanceDetail() ... this works better, but still not nearly as good as in ASPImage, and considerably slower.

Is there any hope of seeing something like e.g. Lanczos3 interpolation implemented in the future?

see this source code ...

Lanczos3, to my knowledge, is the best non-proprietary, high-quality image resampling algorithm available - it is also one of the fastest; not considerably slower than regular bicubic interpolation. It also seems to be what high-end graphics programs use, e.g. Photoshop...
Lanczos3 is available in XnView/NConvert, so i can add it easily in GFL SDK & GFLAx.
Could you send me a sample (resize and not) from ASPImage?
Pierre.
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

here is a quick test, including the source picture for the thumbnails.

this may be a somewhat subjective matter, but if you look closely, I think you will see that the straight GFLAx.Resize is somewhat blurred and less detailed than the other two...

here's another idea: a designated "thumbnail" function might be useful - I could write one myself in ASP of course, like I already did, but a built-in function would be useful to everyone not using ASP ... this function probably shouldn't work like mine, which iterates by calling EnhanceDetail and scaling down to 60% of the image size repeatedly. A better function would be one that sharpens the original image with an appropriate radius and strength, then resizes with Lanczos3 algorithm to obtain a more detailed thumbnail.

Just an idea :)
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

Are you adding Lanczos3 then?

just wondering :)
User avatar
xnview
Author of XnView
Posts: 44572
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

mindplay wrote:Are you adding Lanczos3 then?

just wondering :)
You have it in GFL SDK 2.40
Pierre.
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

on september 27, you said you were going to add it - but the last release (v2.40) is dated july 5th.

so the feature was already there? it's not documented - how does it work?
User avatar
xnview
Author of XnView
Posts: 44572
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

mindplay wrote:on september 27, you said you were going to add it - but the last release (v2.40) is dated july 5th.

so the feature was already there? it's not documented - how does it work?
Houps sorry, not in 2.40 but in next release...
Pierre.
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

i'll be on the lookout for that, then - thanks :)
b.e.wilson
Posts: 26
Joined: Wed Mar 09, 2005 7:44 pm

Post by b.e.wilson »

Just a late observation: ALL resizing to a smaller image results in blurred-looking images. Only applications that sharpen after every resize (and only the most dumbed-down versions would do that automatically) result in a good loking thumbnail.

If you make a thumbnail, sharpen gently afterwards.

In the image processing game there are a few rules about sharpening:

Only sharpen once to get the final image.
Sharpen after a resize to a smaller image.
If you suspect you've oversharpened, you have in reality WAY oversharpened.
Haloes only belong around the heads of angels and saints, not everything in your image.
User avatar
helmut
Posts: 8705
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Post by helmut »

b.e.wilson wrote:Just a late observation: ALL resizing to a smaller image results in blurred-looking images. Only applications that sharpen after every resize (and only the most dumbed-down versions would do that automatically) result in a good loking thumbnail.

If you make a thumbnail, sharpen gently afterwards.

In the image processing game there are a few rules about sharpening:

Only sharpen once to get the final image.
Sharpen after a resize to a smaller image.
If you suspect you've oversharpened, you have in reality WAY oversharpened.
Haloes only belong around the heads of angels and saints, not everything in your image.
Thank you for that good info. :-) It might be also worth while looking at FAQ "How to resize images with text (screenshots)"
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

I guess it's a matter of preference, but I find I get better results if I sharpen a little more, then resize - not the other way around. For thumbnails, I use the following code to scale down the image by two thirds at a time, then sharpening:

Code: Select all

	function ratio (newWidth, newHeight) {
		return (newWidth * newHeight) / (this.objImage.Width * this.objImage.Height);
	}


	function ResizeR (newWidth, newHeight) {
		while (ratio(newWidth, newHeight) < 0.5) {
			objImage.EnhanceDetail();
			objImage.Resize(Math.round(objImage.Width*0.66), Math.round(objImage.Height*0.66));
		}
		if (ratio(newWidth, newHeight) < 0.75)
			objImage.EnhanceDetail();
		objImage.Resize(newWidth, newHeight);
	}
(where "objImage" is a GFLAx image you've loaded)
linojr

GFL_RESIZE_LANCZOS

Post by linojr »

I've been trying to get it to work but I do not see any diference between lanczos and quick. Has it been added to version 2.54? :shock: