Page 3 of 8
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-08T11:56:25-07:00
by fmw42
The latter was more what I was thinking. But rather than do the processing twice, I was trying to modify the sigmoidal curve by creating two luts from gradients (one from linear gradient and the other from sRGB gradient), each one processed with the same -sigmoidal function. Then blend the two luts. Then use the one combined lut to process the image. Of course you have to create the reverse lut as well for the back end from the +sigmoidal function.
Or ramp the two luts so that the dark end gets one and light end gets the other.
Again just thinking out loud with some ideas. Don't know if that will help or make any significant difference.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-08T12:28:23-07:00
by NicolasRobidoux
@Fred: Indeed building one single LUT would be more efficient.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-09T18:17:17-07:00
by anthony
fmw42 wrote:1) Do you find certain conditions that you would process in some linear space (RGB or XYZ) and others where you would process in non-linear space (SRGB or LAB, etc)?
Personally no. But then I often don't bother, I just resize in sRGB colorspace. I don't care that much in quality for my own images. But the Digital Photography, and Image Experts (Nicholas) very much do care.
On the other hand when making a overlapped sequence of images (for example
Overlapping Photos) I have seen examples where doing this in LAB or LUV colorspace just works a lot better than using RGB.
Basically as if you overlap Red and Blue areas , you get really dark results.
Code: Select all
convert xc:red xc:blue -evaluate-sequence mean -scale 100 show:
But in LAB space you get a brighter more accurite response...
Code: Select all
convert xc:red xc:blue -colorspace LAB -evaluate-sequence mean -colorspace sRGB -scale 100 show:
UPDATE: using linear RGB (or XYZ) you get a purple color between the above two results. But that is due to intensity vcetor not being properly separated from color vectors as it is in LAB (or LUV) colorpsace.
Code: Select all
convert xc:red xc:blue -colorspace RGB -evaluate-sequence mean -colorspace sRGB -scale 100 show:
The same goes for Red-Blue gradients. You get a distinct darkening of the colors in the middle.
2) Do you find that white overshoots are better processed by linear vs non-linear colorspace and that black overshoots are better processed by the opposite colorspaces?
If this is the case, you can create a lookup table sigmoidal function that is a ramped blend of applying the sigmoidal function to linear and non-linear gradients. Would that help in any way? You thus can generate a non-symmetric sigmoidal function that might work better for both dark and light overshoots.
Or one might determine the amount of contrast in an image and adjusting the sigmoidal function from working in a linear space or a non-linear space by the amount of contrast.
I am quite certain that Nicolas has it right in his summary. It just makes too much sense in that regard. A more symmetrical 'sigmoidal' variant works better when dealing with super strong edges (in either direction), while a perceptual space colorspace with a skew toward black only works to prevent black (dark) ringing effects, such as visible in the rose.
Note the rose image also have a white ringing effect, but the white area is already at maximum intensity, so you don't see the ringing effect in the white area. That makes it a lot harder to judge.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T14:23:57-07:00
by BryantMoore
Code: Select all
convert rose: -define filter:blur=10 -filter catrom -colorspace rgb +sigmoidal-contrast 11.6933 -sample 1000% -resize 100% -sigmoidal-contrast 11.6933 -colorspace srgb +repage rose-catrom_10x-convolution_gamma-correct_less-safe-sigmoidal-11p6933.png
convert new.png -define filter:blur=10 -filter catrom -colorspace rgb +sigmoidal-contrast 11.6933 -sample 1000% -resize 100% -sigmoidal-contrast 11.6933 -colorspace srgb +repage new_catrom_10x-convolution_gamma-correct_less-safe-sigmoidal-11p6933.png
Did I find the secrete to perfect image resampling?
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T15:07:42-07:00
by NicolasRobidoux
This looks good.
Kinda like using supersampling, uhm?
However, I think that, in the rose, your scheme shows too much color bleed. Look at the bottom of the rose, and where it nearly touches a small white flower.
I'm guessing that fixing this is as easy as backing down the sigmoidization.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T15:09:58-07:00
by NicolasRobidoux
For comparison, here are the results with sigmoidized Ginseng. First, with the "safer" contrast:
Then, with the "less safe" contrast:
Now, the Ginseng enlargements are interpolatory, and actually more than a bit sharper. They also have more artifacts.
So, for a full comparison, I would have to compare the results of your approach with a similarly smoothing method. EWA LanczosSharp, for example.
-----
I'm not saying what you're doing is not brilliant. Just that I don't know for sure yet.
To know, I need more comparisons. Which of course I can produce at home.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T15:49:12-07:00
by NicolasRobidoux
@sunawo13:
Your scheme is very nice. But it's very blurry: More blurry than EWA LanczosSharp (or even EWA Lanczos) with this level of sigmoidization.
It's going to take me a while to find a good basis for comparison.
But I certainly take note that supersampling can do nice things. Good work!
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T16:09:34-07:00
by NicolasRobidoux
@sunawo13:
Here is a scheme with something approaching the level of blurriness of your method. It's still sharper: Some features appear to be washed out by your scheme. And it has more halo and jaggies. But it gives an idea of what you are competing against.
It's sigmoidized EWA Lanczos2 (which is generally considered too blurry):
Code: Select all
magick rose: -colorspace RGB +sigmoidal-contrast 11.6933 -filter Lanczos2 -distort resize 1000% -sigmoidal-contrast 11.6933 -colorspace sRGB roseEWALanczos2Sig11p6933.png
I'm not 100% sure, but I think I could pretty much clone your scheme. The reason is that there is a connection between supersampling and bilinear filtering given that you scale the Catmull-Rom filter, and I should be able to fold this combination into a "one step" filter without having to use an intermediate image produced with -scale.
Then again, the artifact mix on your scheme looks very good, even taking its blurriness into account. So, there is something for me to think about here.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T16:32:04-07:00
by BryantMoore
@NicolasRobidoux
I increased the C parameter on the filter so that it's now an overly sharp Catmull-Rom.
Code: Select all
convert new.png -define filter:blur=10 -define filter:b=0 -define filter:c=1 -filter cubic -colorspace rgb +sigmoidal-contrast 11.6933 -sample 1000% -resize 100% -sigmoidal-contrast 11.6933 -colorspace srgb +repage new_cubic-b0c1-10x-convolution_gamma-correct_less-safe-sigmoidal-11p6933.png
Let me know what you think.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T17:32:23-07:00
by NicolasRobidoux
@sumawo13 (BryantMoore):
At the beginning of this thread, there is a sequence of test images that are enlarged with various ratios.
Would you be kind enough to use these exact test images and enlarge them with the exact same ratios, and then post the results here or, even better, in a new thread about, say "Supersampled sigmoidized Catmull-Rom" or something like that?
Pick the variant of your scheme you like most, but note that the real challenge is to be both sharp and artifact free, while being "faithful". Not that there is no place for blurry schemes. But this is the "real hard" problem.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T17:36:54-07:00
by NicolasRobidoux
@sumawo13 (BryantMoore):
Also, I don't recommend such high values of the sigmoidization contrast, esp. with sharp schemes, anymore. The reason is that occasionally one gets noticeable "color bleed". You may want to pick a value under 10.
But again, it's your scheme!
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T17:57:00-07:00
by NicolasRobidoux
@sumawo13 (BryantMoore):
FYI: After doing a real quick and dirty back of the envelope to model the effect of supersampling through windowing, here is an almost clone of your original scheme, without relying on an intermediate image used to supersample (kind of):
Code: Select all
convert rose: -colorspace RGB +sigmoidal-contrast 11.6933 -define filter:verbose=1 -define filter:filter=CatRom -define filter:window=Triangle -define filter:blur=1.25 -resize 1000% -sigmoidal-contrast 11.6933 -colorspace sRGB roseTriangleWindowedCatromBlur1p25Sig11p6933.png
The result:
It's not a perfect clone (the max abs error is 12), but the point I want to make is that if it was decided that this is a superior scheme, it would most likely be possible to do reproduce it without the intermediate image. Another advantage is that the scheme would work better when the enlargement ratio is not an integer.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T21:25:57-07:00
by BryantMoore
@NicolasRobidoux
I compared a standard Jinc resize to my version using a convolution and sigmoidal contrast and I believe the results show promise.
Jinc Resize
Code: Select all
convert rose: -filter jinc -resize 1000% rose_jinc-resize.png
BAM Scaler
Code: Select all
convert rose: -define filter:blur=10 -filter jinc -colorspace rgb +sigmoidal-contrast 5x100% -sample 1000% -resize 100% -sigmoidal-contrast 5x100% -colorspace srgb +repage rose_bamscaler.png
Let me know what you think.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T21:38:05-07:00
by fmw42
just curious but why
1) are you using -sample and -resize? -sample just magnifies by duplicating pixels (not interpolating them) and -resize 100% is a no-op (in principle and depending upon the filter how good it is at that). To be honest, I do not know if all the filter controls work on -sample and only perhaps on -resize. see
http://www.imagemagick.org/Usage/resize/#sample
2) why are you using the assymmetric -sigmoidal-contrast with the second argument at 100% (that is curved near black and extends linearly to white.
see my sigmoidal script examples page at the link below for such curves.
Re: Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoidal...?
Posted: 2012-09-21T22:01:10-07:00
by BryantMoore
fmw42 wrote:just curious but why
1) are you using -sample and -resize? -sample just magnifies by duplicating pixels (not interpolating them) and -resize 100% is a no-op (in principle and depending upon the filter how good it is at that). To be honest, I do not know if all the filter controls work on -sample and only perhaps on -resize. see
http://www.imagemagick.org/Usage/resize/#sample
2) why are you using the assymmetric -sigmoidal-contrast with the second argument at 100% (that is curved near black and extends linearly to white.
see my sigmoidal script examples page at the link below for such curves.
1)I use -sample + -define filter:blur + -resize 100% because I notice it does a better job of resampling than a direct -resize.
2) I changed my script after reading the documentation more and came up with this.
Code: Select all
convert rose: -define filter:blur=10 -filter jinc -colorspace rgb -sigmoidal-contrast 0.5x10% -sigmoidal-contrast 1.25x75% -sample 1000% -resize 100% -colorspace srgb +repage rose_bamscaler.png
@NicolasRobidoux
I made this comparison.
EDIT
I believe I've finalized
BAM Scaler.
Code: Select all
convert new.png -define filter:window=kaiser -filter sinc -colorspace rgb -sigmoidal-contrast 0.5x10% -sigmoidal-contrast 1.25x85% -distort resize 1000% -colorspace srgb +repage -sampling-factor 1x1 -quality 100% -strip new_bamscaler.png
Hopefully Nicolas can let know what he thinks and maybe even combine it into a single filter for ImageMagick.
Also, here's an example in downsampling, the original image was aliased and 100x larger.
https://dl.dropbox.com/u/106615031/dsp/ ... scaler.jpg