deBayerScissorsdebayer_instance=newdeBayerScissors(debayerParameters.size,// size of the square array, centar is at size/2, size/2, only top half+line will be used
debayerParameters.polarStep,// maximal step in pixels on the maxRadius for 1 angular step (i.e. 0.5)
debayerParameters.debayerRelativeWidthGreen,// result green mask mpy by scaled default (diamond)
debayerParameters.debayerRelativeWidthRedblue,// result red/blue mask mpy by scaled default (square)
debayerParameters.debayerRelativeWidthRedblueMain,// green mask when applied to red/blue, main (center)
debayerParameters.debayerRelativeWidthRedblueClones);// green mask when applied to red/blue, clones
both_masks=debayer_instance.aliasScissors(tile[greenChn],// fht array for green, will be masked in-place
debayerParameters.debayerThreshold,// no high frequencies - use default uniform filter
debayerParameters.debayerGamma,// power function applied to the amplitudes before generating spectral masks
debayerParameters.debayerBonus,// scale far pixels as (1.0+bonus*r/rmax)
debayerParameters.mainToAlias,// relative main/alias amplitudes to enable lixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
debayerParameters.debayerMaskBlur,// for both masks sigma for gaussian blur of the binary masks (<0 -do not use "scissors")
debayerParameters.debayerUseScissors,// use "scissors", if false - just apply "diamond" ands "square" with DEBAYER_PARAMETERS.debayerRelativeWidthGreen and DEBAYER_PARAMETERS.debayerRelativeWidthRedblue
/*This is synchronized method. It is possible to make threads to write to non-overlapping regions of the outPixles, but as the accumulation
* takes just small fraction of severtal FHTs, it should be OK - reasonable number of threads will spread and not "stay in line"
*/
deBayerScissorsdebayer_instance=newdeBayerScissors(debayerParameters.size,// size of the square array, centar is at size/2, size/2, only top half+line will be used
debayerParameters.polarStep,// maximal step in pixels on the maxRadius for 1 angular step (i.e. 0.5)
debayerParameters.debayerRelativeWidthGreen,// result green mask mpy by scaled default (diamond)
debayerParameters.debayerRelativeWidthRedblue,// result red/blue mask mpy by scaled default (square)
debayerParameters.debayerRelativeWidthRedblueMain,// green mask when applied to red/blue, main (center)
debayerParameters.debayerRelativeWidthRedblueClones);// green mask when applied to red/blue, clones
both_masks=debayer_instance.aliasScissors(tile[greenChn],// fht array for green, will be masked in-place
debayerParameters.debayerThreshold,// no high frequencies - use default uniform filter
debayerParameters.debayerGamma,// power function applied to the amplitudes before generating spectral masks
debayerParameters.debayerBonus,// scale far pixels as (1.0+bonus*r/rmax)
debayerParameters.mainToAlias,// relative main/alias amplitudes to enable pixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
debayerParameters.debayerMaskBlur,// for both masks sigma for Gaussian blur of the binary masks (<0 -do not use "scissors")
debayerParameters.debayerUseScissors,// use "scissors", if false - just apply "diamond" ands "square" with DEBAYER_PARAMETERS.debayerRelativeWidthGreen and DEBAYER_PARAMETERS.debayerRelativeWidthRedblue
mainToAlias,// relative main/alias amplitudes to enable lixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
debayer_bonus,// scale far pixels as (1.0+bonus*r/rmax)
this_debug);// relative main/alias amplitudes to enable lixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
/* add double mainToAlias){// relative main/alias amplitudes to enable pixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out) */
privateint[][]polar2CartesianIndices;// for each polar angle/radius (angle*iRadiusPlus1+radius) - 4 interpolation corners (0:0, dx:0, 0:dy, dx:dy), the first (0:0) being the closest to the polar point
privatedouble[][]polar2CartesianFractions;// a pair of dx, dy for interpolations (used with ) polar2CartesianIndices[][]]
privateint[][]cartesian2PolarIndices;// each per-pixel array is a list of indices in polar array pointing to this cell (may be empty)
privateint[]cartesian2PolarIndex;// Cartesian->polar array index (cell closest to the center). Is it possible that cartesian2PolarIndices does not include this one?
privateint[][]polarGreenMap=null;// each element is a variable length integer array with a list of the alias indices
privateint[][]polarRedBlueMap=null;// each element is a variable length integer array with a list of the alias indices
privateint[][]sameCartesian=null;// each element is a variable length integer array with a list of indices of the other polar cells that belong (point to) the same cartesian cell
privateint[]cartAmpList=null;// list of indices of the elements of the cartesian array (symmetrical around the center) so the distance is between ampRMinMax[0] and ampRMinMax[1]
privatedouble[]ampRMinMax={0.0,0.0};
publicPolarSpectrums(){}// so "Compile and Run" will be happy
/* Convert cartesian to polar array, dimensions are set in the class constructor. Uses bi-linear interpolation */
/* Caculates maximal value of a center-symmetrical array of the amplitudes in a ring. Uses cached table of indices, recalculates if it changed */
publicdoublemaxAmpInRing(double[]amps){returnmaxAmpInRing(amps,size*0.118,size*0.236);}// ~=1/3* (Math.sqrt(2)/4), 2/3* (Math.sqrt(2)/4) (center 1/3 ring between center and the closest alias for greens)
int[]rayLength=newint[iAngle+1];// index (radius)) of the current ray end for this angle
boolean[]rayOpen=newboolean[iAngle+1];// this ray can grow (not blocked)
for(i=0;i<iAngle;i++){
rayLength[i]=0;
rayOpen[i]=true;
}
intlastIndex;
intbase;
intl;
doublemax;
intnewVal;
intstep=0;
intiMax=0;// index of the best ray
intindex=0;
booleangood=true;
while(iMax>=0){
step++;
/* add polar point index */
newVal=good?step:-step;
// index=iMax*iRadiusPlus1+rayLength[iMax]; // rayLength[iMax] should point to a new cell (with intMap[]==0) may ommit - set in the end of the loop and before the loop?
/* Create per-polar pixel list of aliases for green Bayer. For each polar point it shows the polar coordinates of the same (and rotated by pi) point of aliases */
/* current implementation - us cartesian (original) pixels as all/nothing, maybe it makes sense to go directly polar-polar, but then it may leave gaps */
mainToAlias,// relative main/alias amplitudes to enable pixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
debayer_bonus,// scale far pixels as (1.0+bonus*r/rmax)
this_debug);// relative main/alias amplitudes to enable pixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out)
/* add double mainToAlias){// relative main/alias amplitudes to enable pixels (i.e. 0.5 means that if alias is >0.5*main, the pixel will be masked out) */
privateint[][]polar2CartesianIndices;// for each polar angle/radius (angle*iRadiusPlus1+radius) - 4 interpolation corners (0:0, dx:0, 0:dy, dx:dy), the first (0:0) being the closest to the polar point
privatedouble[][]polar2CartesianFractions;// a pair of dx, dy for interpolations (used with ) polar2CartesianIndices[][]]
privateint[][]cartesian2PolarIndices;// each per-pixel array is a list of indices in polar array pointing to this cell (may be empty)
privateint[]cartesian2PolarIndex;// Cartesian->polar array index (cell closest to the center). Is it possible that cartesian2PolarIndices does not include this one?
privateint[][]polarGreenMap=null;// each element is a variable length integer array with a list of the alias indices
privateint[][]polarRedBlueMap=null;// each element is a variable length integer array with a list of the alias indices
privateint[][]sameCartesian=null;// each element is a variable length integer array with a list of indices of the other polar cells that belong (point to) the same cartesian cell
privateint[]cartAmpList=null;// list of indices of the elements of the cartesian array (symmetrical around the center) so the distance is between ampRMinMax[0] and ampRMinMax[1]
privatedouble[]ampRMinMax={0.0,0.0};
publicPolarSpectrums(){}// so "Compile and Run" will be happy
/* Convert cartesian to polar array, dimensions are set in the class constructor. Uses bi-linear interpolation */
/* Caculates maximal value of a center-symmetrical array of the amplitudes in a ring. Uses cached table of indices, recalculates if it changed */
publicdoublemaxAmpInRing(double[]amps){returnmaxAmpInRing(amps,size*0.118,size*0.236);}// ~=1/3* (Math.sqrt(2)/4), 2/3* (Math.sqrt(2)/4) (center 1/3 ring between center and the closest alias for greens)
int[]rayLength=newint[iAngle+1];// index (radius)) of the current ray end for this angle
boolean[]rayOpen=newboolean[iAngle+1];// this ray can grow (not blocked)
for(i=0;i<iAngle;i++){
rayLength[i]=0;
rayOpen[i]=true;
}
intlastIndex;
intbase;
intl;
doublemax;
intnewVal;
intstep=0;
intiMax=0;// index of the best ray
intindex=0;
booleangood=true;
while(iMax>=0){
step++;
/* add polar point index */
newVal=good?step:-step;
// index=iMax*iRadiusPlus1+rayLength[iMax]; // rayLength[iMax] should point to a new cell (with intMap[]==0) may ommit - set in the end of the loop and before the loop?
/* Create per-polar pixel list of aliases for green Bayer. For each polar point it shows the polar coordinates of the same (and rotated by pi) point of aliases */
/* current implementation - us cartesian (original) pixels as all/nothing, maybe it makes sense to go directly polar-polar, but then it may leave gaps */