Page 1 of 1

BAM Scaler

Posted: 2012-09-23T13:52:02-07:00
by BryantMoore
I think I'm getting closer to what I want to do with BAM Scaler.

https://dl.dropbox.com/u/106615031/dsp/ ... scaler.png

I'm not embedding the image because it's over 2MiB in size. The original file is 7680x4320.

Code: Select all

#!/bin/bash
convert 0000.tga \( +clone -colorspace rgb +sigmoidal-contrast 8 -filter cubic -distort resize 1920 -sigmoidal-contrast 8 -colorspace srgb \) \( +clone -define convolve:scale='50%!' -bias 50% -morphology convolve sobel \) -delete 0 -compose overlay -composite +repage -sampling-factor 1x1 -quality 100% -strip bamscaler.png
Here's the impulse response of the filter.

Image

Basically what I'm doing is a gamma correct symmetrical cubic resampling with sigmoidal contrast adjustment and a high-pass filter afterwards to amplify some of the high frequency content. I think I want to use this filter mainly for downsampling.

Any suggestions or criticism is highly appreciated. :)

Re: BAM Scaler

Posted: 2012-09-24T00:52:28-07:00
by BryantMoore
Okay I think I've finally decided on my settings.

Aliased 1280x720
Image

Antialiased from 5120x2880
Image

Impulse response
Image

Code: Select all

convert 0001.tga \( +clone -colorspace rgb +sigmoidal-contrast 8 -filter cubic -distort resize 1280 -sigmoidal-contrast 8 -colorspace srgb \) \( +clone -define convolve:scale='50%!' -bias 50% -morphology convolve sobel \) -delete 0 -compose vivid-light -composite +repage -sampling-factor 1x1 -quality 100% -strip bamscaler.png
:)

Re: BAM Scaler

Posted: 2012-09-24T02:20:01-07:00
by BryantMoore
Aliased 1280x720
Image

Antialiased from 20480x11520 w/ BAM Scaler
Image

Code: Select all

convert large.png \( +clone -colorspace rgb +sigmoidal-contrast 8 -filter cubic -distort resize 1280 -sigmoidal-contrast 8 -colorspace srgb \) \( +clone -define convolve:scale='50%!' -bias 50% -morphology convolve sobel \) -delete 0 -compose overlay -composite +repage -sampling-factor 1x1 -quality 100% -strip downsampled.png
I definitely think I'm happy with this as a downsampling filter. So if this can be integrated into ImageMagick that would make me happy. I think I want it to be called bamsampler. :)

Re: BAM Scaler

Posted: 2012-09-24T03:34:41-07:00
by henrywho
Can we have one or two of the full sized originals for testing?

Re: BAM Scaler

Posted: 2012-09-24T04:27:44-07:00
by BryantMoore
henrywho wrote:Can we have one or two of the full sized originals for testing?
I only have the original for the second image.

https://dl.dropbox.com/u/106615031/dsp/ ... e-comp.png

:)

EDIT

bamsampler2

Image

Code: Select all

convert large-comp.png \( +clone -colorspace rgb +sigmoidal-contrast 8 -define filter:kaiser-beta=4 -define filter:window=kaiser -filter jinc -distort resize 1280 -sigmoidal-contrast 8 -colorspace srgb \) \( +clone -define convolve:scale='50%!' -bias 50% -morphology convolve sobel \) -delete 0 -compose overlay -composite +repage -sampling-factor 1x1 -quality 100% -strip downsampled2.png
Image

Re: BAM Scaler

Posted: 2012-09-24T14:08:52-07:00
by NicolasRobidoux
BAMscaler turns the eyes of the fly to rust.
It actually is not faithful tone wise elsewhere as well. By a lot.
And it is very blurry. And yet it has occasional significant halo, which often can be attributed to "color separation" combined, I would guess, with the Sobel.
Same with the backpack.
P.S. I gave up on downloading your test image after half an hour of slow trickle.
P.S. 2 The above had to do with the BAM which uses Cubic (really, Spline) to do the hard work. I'll try your latest.

Re: BAM Scaler

Posted: 2012-09-24T15:52:15-07:00
by NicolasRobidoux
The Kaiser scheme is tonally unfaithful when there is texture, like the previous scheme. (No surprise: sigmoidization appears to be almost always a bad idea when downsampling, despite what I stupidly suggested in the first pass of my "Recommendations".)
It also has an immense amount of halo given how sharp it is, it is quite jaggy, and the moire is horrible on the fly.

Re: BAM Scaler

Posted: 2012-09-24T17:05:08-07:00
by BryantMoore
@NicolasRobidoux

Kaiser w/o Sigmoidal Contrast
https://dl.dropbox.com/u/106615031/dsp/ ... ampler.png

Code: Select all

convert large.png -colorspace rgb -define filter:kaiser-beta=4 -define filter:window=kaiser -filter jinc -distort resize 1920 -colorspace srgb -sampling-factor 1x1 -quality 100% -strip downsample-bamsampler.png 
Kaiser w/ Sigmoidal Contrast 8
https://dl.dropbox.com/u/106615031/dsp/ ... r-sig8.png

Code: Select all

convert large.png -colorspace rgb +sigmoidal-contrast 8 -define filter:kaiser-beta=4 -define filter:window=kaiser -filter jinc -distort resize 1920 -sigmoidal-contrast 8 -colorspace srgb -sampling-factor 1x1 -quality 100% -strip downsample-bamsampler-sig8.png
PSNR: 43.7049dB
https://dl.dropbox.com/u/106615031/dsp/ ... ompare.png

Source image is 30720x17280; too large to upload here.

Re: BAM Scaler

Posted: 2012-09-24T17:40:13-07:00
by NicolasRobidoux
@Bryant:
The only high frequency components of your latest image are sharp interfaces between essentially flat colour areas, exactly the type of thing sigmoidization does well at.
Because the only "drift" is along boundaries, of course you don't see colour drift.

Re: BAM Scaler

Posted: 2012-09-25T07:55:39-07:00
by BryantMoore
NicolasRobidoux wrote:@Bryant:
The only high frequency components of your latest image are sharp interfaces between essentially flat colour areas, exactly the type of thing sigmoidization does well at.
Because the only "drift" is along boundaries, of course you don't see colour drift.
Perhaps this image has more high frequencies.

Original 1920x1080
Image

256x supersampling w/ bamscaler3
Image

Code: Select all

convert large.tga -define filter:lobes=2 -define filter:kaiser-beta=4 -define filter:window=kaiser -filter jinc -distort resize 1920 downsample-bamsampler.png
From what I've been testing, converting to linear RGB and back to sRGB seems to only damage the downsampling, as does sigmoidal-contrast.

Impulse Response
Image

Maybe you could link me to the fly image so I could test my filters on that? I need something that generates moire patterns. :)

Re: BAM Scaler

Posted: 2012-09-25T08:12:10-07:00
by NicolasRobidoux

Re: BAM Scaler

Posted: 2012-09-25T09:48:01-07:00
by BryantMoore
bamscaler4
Image

Code: Select all

convert fly.jpg -colorspace rgb +sigmoidal-contrast 8 -define filter:blur=1 -define filter:support=2 -define filter:win-support=2 -define filter:kaiser-beta=4 -define filter:window=kaiser -define filter:filter=bessel -distort resize 25% -sigmoidal-contrast 8 -colorspace srgb downsample-bamsampler.png
Seems to produce some significant moire in the eyes, not sure how to combat that currently; it handles the CG images rather well. I suspect the moire would only be worse at non-integer downsamplings.

CG example of the current revision:
http://puu.sh/18xk6

Re: BAM Scaler

Posted: 2012-09-25T11:06:42-07:00
by NicolasRobidoux
The "standard" test I and others use with the fly is resizing to exactly 403x600. Then, you can compare to the million versions of this test I have in the Forums. This is not an integer ratio by any means.

Re: BAM Scaler

Posted: 2012-09-25T14:22:58-07:00
by BryantMoore
NicolasRobidoux wrote:The "standard" test I and others use with the fly is resizing to exactly 403x600. Then, you can compare to the million versions of this test I have in the Forums. This is not an integer ratio by any means.
Image

Code: Select all

convert fly.jpg -colorspace rgb +sigmoidal-contrast 8 -define filter:blur=1.25 -define filter:support=2 -define filter:sigma=1.414 -define filter:win-support=2 -define filter:window=gaussian -define filter:filter=bessel -distort resize 403 -sigmoidal-contrast 8 -colorspace srgb downsample-bamsampler.png
I think this might be as good as it gets on my end.