BAM Scaler

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

BAM Scaler

Post by BryantMoore » 2012-09-23T13:52:02-07:00

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. :)

BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-24T00:52:28-07:00

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
:)

BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-24T02:20:01-07:00

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. :)

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

Re: BAM Scaler

Post by henrywho » 2012-09-24T03:34:41-07:00

Can we have one or two of the full sized originals for testing?

BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-24T04:27:44-07:00

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

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

Re: BAM Scaler

Post by NicolasRobidoux » 2012-09-24T14:08:52-07:00

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.

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

Re: BAM Scaler

Post by NicolasRobidoux » 2012-09-24T15:52:15-07:00

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.

BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-24T17:05:08-07:00

@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.

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

Re: BAM Scaler

Post by NicolasRobidoux » 2012-09-24T17:40:13-07:00

@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.

BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-25T07:55:39-07:00

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. :)

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

Re: BAM Scaler

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


BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-25T09:48:01-07:00

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

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

Re: BAM Scaler

Post by NicolasRobidoux » 2012-09-25T11:06:42-07:00

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.

BryantMoore
Posts: 56
Joined: 2011-04-23T22:21:52-07:00
Authentication code: 8675308

Re: BAM Scaler

Post by BryantMoore » 2012-09-25T14:22:58-07:00

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.

Post Reply