* Select low-textured tiles for averaging measurements
* Select low-textured tiles for averaging measurements
* @param min_disparity minimal disparity to accept
* @param min_disparity minimal disparity to accept
* @param max_density maximal trusted tile density (density varies from 0.0 to 1.0)
* @param max_density maximal trusted tile density (density varies from 0.0 to 1.0)
* @param grow grow selection. When combined with shrink, fills small gaps. Both grow and shrink step
* @param grow how many layers of tiles should be added after filling gaps and removing small clusters
* advances either horizontally or vertically (alternating), so to expand by 1 pixel in all directions
* @param max_gap_radius maximal radius of a void to be filled
* the value should be set to 2,
* @param min_clust_radius minimal original cluster radius to survive
* @param shrink shrink selection after expanding to fill small gaps
* @param density per-tile values of the density of trusted tiles around it.
* @param density per-tile values of the density of trusted tiles around it.
* @param src_disparity - source disparity array
* @param src_disparity - source disparity array. If null will only use density (that should be > 0)
* @return selection of the low-textured tiles to be processed with averaging correlation (3x3 or 5x5 tiles)
* @return selection of the low-textured tiles to be processed with averaging correlation (3x3 or 5x5 tiles)
*/
*/
publicboolean[]selectLowTextures(
publicboolean[]selectLowTextures(
doublemin_disparity,
doublemin_disparity,
doublemax_density,
doublemax_density,
intgrow,
intgrow,
intshrink,
intmax_gap_radius,
intmin_clust_radius,
double[]density,
double[]density,
double[]src_disparity)
double[]src_disparity)
{
{
boolean[]selection=newboolean[density.length];
boolean[]selection=newboolean[density.length];
if(src_disparity==null){
for(intnTile=0;nTile<selection.length;nTile++){
if((density[nTile]<=max_density)&&(density[nTile]<=max_density)){// disparity has NaN-s, they will fail comparisons
selection[nTile]=true;
}
}
}else{
for(intnTile=0;nTile<selection.length;nTile++){
for(intnTile=0;nTile<selection.length;nTile++){
if((src_disparity[nTile]>=min_disparity)&&(density[nTile]<=max_density)){// disparity has NaN-s, they will fail comparisons
if((src_disparity[nTile]>=min_disparity)&&(density[nTile]<=max_density)){// disparity has NaN-s, they will fail comparisons
selection[nTile]=true;
selection[nTile]=true;
}
}
}
}
}
finalTileNeibstnImage=biCamDSI.tnImage;
finalTileNeibstnImage=biCamDSI.tnImage;
tnImage.growSelection(
tnImage.growSelection(
grow,// int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
2*max_gap_radius,// int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
selection,// boolean [] tiles,
null);// boolean [] prohibit)
tnImage.shrinkSelection(
2*(max_gap_radius+min_clust_radius),// int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
selection,// boolean [] tiles,
null);// boolean [] prohibit)
tnImage.growSelection(
2*(min_clust_radius+grow),// int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more