Hi,
here is another experiment I did. I wanted to find out how those transforms behave for different saturations. The attached pictures show this:
- top row (left to right): Color Palette (0.75 saturation), HistogramTransform
- second row (left to right): same as above, V-Transform result
- 3rd row (left to right): Color Palette (0.1 saturation), HistogramTransform, Saturation Boost (9.0)
- 4th row (left to right): same as above, V-Transform, Saturation Boost (9.0)
The results basically confirm that HistogramTransform is not very good a preserving color, even after saturation boosts. V-Transform does a better job (in both scenarios). Unexpected for me was the apparent modulation in color in the saturation boosted V-Transform result (bottom right): Especially the yellow and pink parts vanish in the darker regions. I have no idea why that is the case.
Below the script used to create the palettes.
Cheers,
Georg
#include <pjsr/ColorSpace.jsh>
#include <pjsr/SampleType.jsh>
#include <pjsr/UndoFlag.jsh>
//from http://www.tecgraf.puc-rio.br/~mgattass/color/HSVtoRGB.htm
function HSVtoRGB(h,s,v){
var r,h,b;
if ( s == 0 ) {
r = v;
g = v;
b = v;
}else{
var var_h = h * 6;
var var_i = Math.floor( var_h );
var var_1 = v * ( 1 - s );
var var_2 = v * ( 1 - s * ( var_h - var_i ) );
var var_3 = v * ( 1 - s * ( 1 - ( var_h - var_i ) ) );
if ( var_i == 0 ) { r = v; g = var_3 ; b = var_1; }
else if ( var_i == 1 ) { r = var_2 ; g = v; b = var_1; }
else if ( var_i == 2 ) { r = var_1 ; g = v; b = var_3; }
else if ( var_i == 3 ) { r = var_1 ; g = var_2 ; b = v; }
else if ( var_i == 4 ) { r = var_3 ; g = var_1 ; b = v; }
else { r = v; g = var_1 ; b = var_2; }
}
return new Array(r,g,b);
}
function main() {
var rows=150;
var cols=300;
var saturation=0.1; //0.75 or 0.1;
var maxValue=1.0;
var image = new Image(cols,rows,3,ColorSpace_RGB,32,SampleType_Real);
for (var col=0;col<cols;++col){
var factor=Math.exp(-col/60);
var value=maxValue*factor;
for (var row=0;row<rows;++row){
var hue=row/rows;
RGB=HSVtoRGB(hue,saturation,value);
for (var chan=0;chan<3;++chan){
image.setSample(RGB[chan],col,row,chan);
}
}
}
image.resetSelections();
var wtmp = new ImageWindow( image.width, image.height, image.numberOfChannels,
image.bitsPerSample,image.sampleType == SampleType_Real,
image.isColor, "tmp" );
var v = wtmp.mainView;
v.beginProcess( UndoFlag_NoSwapFile );
v.image.assign( image );
v.endProcess();
wtmp.show();
}
main();