Page 4 of 8

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T06:29:30-07:00
by NicolasRobidoux
@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.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T06:38:05-07:00
by NicolasRobidoux
@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.
Image

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

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T09:59:46-07:00
by BryantMoore
@NicolasRobidoux
The latest version of my filter uses direct resampling as opposed to "supersampling".
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
Here's an example.

Triangle
Image

BAM Scaler
Image

Here is the original skull image.

Image

:)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T10:16:28-07:00
by fmw42
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.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T10:31:33-07:00
by NicolasRobidoux
@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"):
Image
(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:
Image
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

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T10:48:27-07:00
by NicolasRobidoux
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.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T11:23:44-07:00
by BryantMoore
@NicolasRobidoux
I think I might have found satisfactory settings. :)

Triangle
Image

BAM Scaler
Image
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

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T11:29:37-07:00
by NicolasRobidoux
No argument here. ;)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T11:36:32-07:00
by BryantMoore
Could it possibly be turned into an ImageMagick filter? :)

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T12:29:18-07:00
by magick
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.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T13:04:54-07:00
by NicolasRobidoux
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.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T13:40:19-07:00
by BryantMoore
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.
I'd like the name to be bam or bamscaler. Thanks guys I appreciate all your critique and support! :)

EDIT

It seems my filter is very similar to Nicolas' "scheme of the day" filter; give me some time to tune my settings guys! :D

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T14:51:44-07:00
by fmw42
what does bam mean?

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T15:58:04-07:00
by NicolasRobidoux
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.

Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?

Posted: 2012-09-22T22:24:36-07:00
by BryantMoore
fmw42 wrote:what does bam mean?
BAM are my initials :)

Default
Image

Latest BAM Scaler revision
Image
#!/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
I think I have it how I want it at this point. :)

EDIT

Here's an enlargement of a white pixel with 1px black border by 100x.

Triangle
Image

Default
Image

BAM Scaler
Image
#!/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
@NicolasRobidoux
What do you think of it now? :)