Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal,... gamma?
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
@sumawo13 (BryantMoore):
I'm sorry, but I'm not convinced.
Besides that I'm not particularly impressed with how "BAM" looks, I have a technical objection.
Basically, what you are doing is emulating, by "supersampling", a combination of windowing and slightly blurring (in the sense of -define filter:blur={value}) the filter you are using.
Most likely, this approach will suffer greatly when your enlargement or downsampling ratio is not an integer. Especially near 100% (as in enlarging an 100x200 image to 113x226).
I would rather you window and blur the filters directly, without using -scale.
I don't really know what the gamma etc are about and why, or whether they are better. Maybe.
But so far, I have not seen something that makes me want to ditch one of my favorite methods for yours.
-----
Now, James Dyson made more than 5000 prototypes of his vacuum cleaner before he made "the one".
P.S. I know I'm biased.
I'm sorry, but I'm not convinced.
Besides that I'm not particularly impressed with how "BAM" looks, I have a technical objection.
Basically, what you are doing is emulating, by "supersampling", a combination of windowing and slightly blurring (in the sense of -define filter:blur={value}) the filter you are using.
Most likely, this approach will suffer greatly when your enlargement or downsampling ratio is not an integer. Especially near 100% (as in enlarging an 100x200 image to 113x226).
I would rather you window and blur the filters directly, without using -scale.
I don't really know what the gamma etc are about and why, or whether they are better. Maybe.
But so far, I have not seen something that makes me want to ditch one of my favorite methods for yours.
-----
Now, James Dyson made more than 5000 prototypes of his vacuum cleaner before he made "the one".
P.S. I know I'm biased.
Last edited by NicolasRobidoux on 2012-09-22T10:00:45-07:00, edited 4 times in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
@sumawo13 (BryantMoore):
I don't have the original of your "skull" image, but here is the rose with one of my recent prototypes. Completely different in terms of approach from what I've done before: I'm windowing Jinc without deblurring it. (Inspired by Henry HO's shared dislike of the second halos. Also inspired by your attempts at making things "look good", without much regard to "accuracy".)
Still needs works, and it may be a disaster with other test images or in other situations, but it's sharp, it has almost no jaggies, the halos are bearable, and it's faithful. A good start.
Likely to be one of the 5000 prototypes going to the Nicolas Museum of Ditched Methods. For one thing, the contrast seems a touch high.
P.S. Of course, trying various windows with EWA Jinc was a logical next step. But trying Parzen and Quadratic is particularly appealing if you understand what windowing does: it can very very roughly be understood as prefiltering before feeding to the low pass filter, and it can also be understood as dampening the filter near the end of its extent in order to minimize halo. Parzen and Quadratic are C^2 and C^1 windows, respectively, that are very strongly bell curved (they actually are good approximations of Gaussian blur, being obtained by repeated Box filtering), and so nearly kill the outmost halo. On paper, they have a lot to commend them for, provided a sufficient number of lobes (=3 above), and a sufficiently large "blur" parameter (=1 above, remembering that Jinc 3-lobe extends farther than Sinc 3-lobe), are used. Quadratic seems to work really well with Jinc. I would guess that Parzen would work well with 4 or 5 lobes.
I don't have the original of your "skull" image, but here is the rose with one of my recent prototypes. Completely different in terms of approach from what I've done before: I'm windowing Jinc without deblurring it. (Inspired by Henry HO's shared dislike of the second halos. Also inspired by your attempts at making things "look good", without much regard to "accuracy".)
Still needs works, and it may be a disaster with other test images or in other situations, but it's sharp, it has almost no jaggies, the halos are bearable, and it's faithful. A good start.
Likely to be one of the 5000 prototypes going to the Nicolas Museum of Ditched Methods. For one thing, the contrast seems a touch high.
Code: Select all
convert rose: -colorspace RGB +sigmoidal-contrast 10.5 \
-define filter:window=Quadratic -distort resize 1000% \
-sigmoidal-contrast 10.5 -colorspace sRGB roseEWAQuadraticJincSig10.5.png
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
@NicolasRobidoux
The latest version of my filter uses direct resampling as opposed to "supersampling".
Triangle
BAM Scaler
Here is the original skull image.
The latest version of my filter uses direct resampling as opposed to "supersampling".
Here's an example.convert new.png -define filter:kaiser-beta=4 -define filter:window=kaiser -filter sinc -colorspace rgb -sigmoidal-contrast 1.25x10% -distort resize 1333% -colorspace srgb +repage -sampling-factor 1x1 -quality 100% -strip new_bamscaler2_1333percent.jpg
Triangle
BAM Scaler
Here is the original skull image.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Saving as jpg (a compressed format that causes color changes and artifacts from compression) is generally not a good idea when trying to make comparisons of different techniques. It would be better too save as PNG. Even at -quality 100 it is still lossy.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
@sumawo13 (BryantMoore):
(Note that the skull is not a particularly good test image because it's really hard to know what the enlargement is supposed to look like.)
BAM2 "solarizes" the shadows. This is not "accurate".
Also, it changes the luminance and tones. It simply is not faithful. It's darker.
Please compare, by flickering, with the following enlargement performed with nearest neighbour (does not look good, but is quite good at preserving "colour"):
(Also: Unless you specifically want to compare with bilinear, please don't compare with -resize Triangle, which everybody knows is dreadful unless used for downsampling.)
Compare, for example, with my "scheme of the day", namely sigmoidized (with the "less safe" contrast) EWA Jinc 2-lobe windowed with quadratic B-spline:
It's faithful (flicker with the nearest neighbour enlargement shown above), and it's reasonably artifact free. (No over the top halo, for one thing.)
(Note that I will not do more tests with the skull image. It is not a good test image.)
P.S. Here is the code:
(Note that the skull is not a particularly good test image because it's really hard to know what the enlargement is supposed to look like.)
BAM2 "solarizes" the shadows. This is not "accurate".
Also, it changes the luminance and tones. It simply is not faithful. It's darker.
Please compare, by flickering, with the following enlargement performed with nearest neighbour (does not look good, but is quite good at preserving "colour"):
(Also: Unless you specifically want to compare with bilinear, please don't compare with -resize Triangle, which everybody knows is dreadful unless used for downsampling.)
Compare, for example, with my "scheme of the day", namely sigmoidized (with the "less safe" contrast) EWA Jinc 2-lobe windowed with quadratic B-spline:
It's faithful (flicker with the nearest neighbour enlargement shown above), and it's reasonably artifact free. (No over the top halo, for one thing.)
(Note that I will not do more tests with the skull image. It is not a good test image.)
P.S. Here is the code:
Code: Select all
convert new.png -colorspace RGB +sigmoidal-contrast 8.125 -define filter:window=Quadratic -distort resize 1333% -sigmoidal-contrast 8.125 -colorspace sRGB skull.EWAQuadraticJincSig8p125.png
Last edited by NicolasRobidoux on 2012-09-22T12:05:53-07:00, edited 2 times in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
There is one thing that BAM2 did better than my scheme of the day: The "pink" spot on the nose is better. But then, I used the "less safe" sigmoidal contrast, so this serves me right.
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
@NicolasRobidoux
I think I might have found satisfactory settings.
Triangle
BAM Scaler
I think I might have found satisfactory settings.
Triangle
BAM Scaler
convert new.png -colorspace RGB +sigmoidal-contrast 12 -define filter:window=quadratic -filter jinc -distort resize 1333% -sigmoidal-contrast 12 -colorspace sRGB -sampling-factor 1x1 -quality 100% -strip skull_1333p_jinc-quadratic-gamma-sig8p125.png
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
No argument here.
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Could it possibly be turned into an ImageMagick filter?
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Yes. Post a name for the filter and we'll code it up in IMv7 Alpha. If it proves useful, we can backport it to IMv6.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Not totally sure yet, but the "scheme of the day" seems to work well for downsampling: viewtopic.php?f=1&t=20992&start=225#p90394.
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
I'd like the name to be bam or bamscaler. Thanks guys I appreciate all your critique and support!magick wrote:Yes. Post a name for the filter and we'll code it up in IMv7 Alpha. If it proves useful, we can backport it to IMv6.
EDIT
It seems my filter is very similar to Nicolas' "scheme of the day" filter; give me some time to tune my settings guys!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
what does bam mean?
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
At equivalent sigmoidization, EWA quadratic B-spline-windowed Jinc 3 definitely loses to EWA LanczosSharp (when enlarging, the only case where I recommend sigmoidization across the board). The only reason to use it would be that it has less halo.
It's when downsampling that the better moire suppression of EWA quadratic B-spline-windowed Jinc 3, combined with its essentially inexistent second halo, may make it a better scheme. But it's most likely not a winner for upsampling.
It's when downsampling that the better moire suppression of EWA quadratic B-spline-windowed Jinc 3, combined with its essentially inexistent second halo, may make it a better scheme. But it's most likely not a winner for upsampling.
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
BAM are my initialsfmw42 wrote:what does bam mean?
Default
Latest BAM Scaler revision
I think I have it how I want it at this point.#!/bin/bash
for f in *.jpg;
do
convert $f -colorspace RGB -sigmoidal-contrast 0.45x50% -define filter:kaiser-beta=4 -define filter:window=kaiser -filter sinc -distort resize 25% -sigmoidal-contrast 0.45x50% -colorspace sRGB -sampling-factor 1x1 -quality 100% -strip $f-bamscaler.jpg
done
EDIT
Here's an enlargement of a white pixel with 1px black border by 100x.
Triangle
Default
BAM Scaler
@NicolasRobidoux#!/bin/bash
convert xc: -bordercolor black -border 1x1 -colorspace RGB -sigmoidal-contrast 0.45x50% -define filter:kaiser-beta=4 -define filter:window=kaiser -filter sinc -distort resize 10000% -sigmoidal-contrast 0.45x50% -colorspace sRGB -sampling-factor 1x1 -quality 100% -strip 3x3-bamscaler.jpg
convert xc: -bordercolor black -border 1x1 -resize 10000% -sampling-factor 1x1 -quality 100% -strip 3x3-default.jpg
convert xc: -bordercolor black -border 1x1 -filter triangle -resize 10000% -sampling-factor 1x1 -quality 100% -strip 3x3-triangle.jpg
What do you think of it now?
Last edited by BryantMoore on 2015-04-02T03:57:50-07:00, edited 1 time in total.