Skip to content

Commit

Permalink
fix z weight function
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPreibisch committed Aug 18, 2023
1 parent 20d764f commit fe4d967
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ public static void main( final String[] args ) throws IOException
final BlockCollection< ?, AffineModel2D, ?, ZBlockFactory > blockCollection =
solverSetup.setupSolve( cmdLineSetup.blockModel(), cmdLineSetup.stitchingModel() );

// test weight function

BlockData<?, AffineModel2D, ?, ZBlockFactory> b = blockCollection.allBlocks().get( 0 );

for ( int z = b.minZ() - 1; z <= b.maxZ() + 1; ++z )
{
System.out.println( z + ": " + b.createWeightFunctions().get( 2 ).apply( (double)z ) );
}

System.exit( 0 );

//
// multi-threaded solve
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static List< ZBlockInit > defineBlockLayout( final int minZ, final int ma

@SuppressWarnings("unchecked")
@Override
public ArrayList<Function<Double, Double>> createWeightFunctions( final BlockData<?, ?, ?, ZBlockFactory > block)
public ArrayList<Function<Double, Double>> createWeightFunctions( final BlockData<?, ?, ?, ZBlockFactory > block )
{
// we also define our own distance functions
// here, xy doesn't matter, only z
Expand All @@ -183,13 +183,11 @@ public ArrayList<Function<Double, Double>> createWeightFunctions( final BlockDat
weightF.add( (Function< Double, Double > & Serializable )(y) -> 0.0 );
// TODO: has to be between 0 and 1
// TODO: needs the Block to know
weightF.add( (Function< Double, Double > & Serializable )(z) ->
1.0 -
(
Math.abs( z - ( ( block.maxZ() - block.minZ() ) / 2. + block.minZ() ) )
/
( block.maxZ() - block.minZ() ) / 2.
)
weightF.add( (Function< Double, Double > & Serializable )(z) ->
1.0 - Math.min( 1, Math.max( 0,
( Math.abs( z - ( ( block.maxZ() - block.minZ() ) / 2. + block.minZ() ) ) /
( ( block.maxZ() - block.minZ() ) / 2. + 0.01) ) // first and last z-slice not 0.0
) )
);

return weightF;
Expand Down

0 comments on commit fe4d967

Please sign in to comment.