ViewerTransformAdjuster for multiple sources
Closed this issue · 4 comments
tischi commented
you have there code like this:
RealInterval maxInterval = intervalList.stream()
.reduce((i1,i2) -> new FinalRealInterval(
new double[]{Math.min(i1.realMin(0), i2.realMin(0)), Math.min(i1.realMin(1), i2.realMin(1)), Math.min(i1.realMin(2), i2.realMin(2))},
new double[]{Math.max(i1.realMax(0), i2.realMax(0)), Math.max(i1.realMax(1), i2.realMax(1)), Math.max(i1.realMax(2), i2.realMax(2))}
)).get();
Is that maybe rather the union interval?
If so, could one just use the inbuilt Intervals.union
for this?
NicoKiaru commented
Ah nice! I didn't know it exists. But is union really union ?
Because [1..3] union [5..7] is not supposed to be [1..7], but [1..3]U[5..7].
I guess it's just a naming problem. With Intervals we always get bounds and not a 'real' union.
tischi commented
Good point. Javadoc says: "Compute the smallest interval that contains both input intervals."
I have a TransformHelpers class with such code:
public static RealInterval unionRealInterval( List< ? extends Source< ? > > sources )
{
RealInterval union = null;
for ( Source< ? > source : sources )
{
final FinalRealInterval bounds = estimateBounds( source );
if ( union == null )
union = bounds; // init with first source
else
union = Intervals.union( bounds, union );
}
return union;
}
public static FinalRealInterval estimateBounds( Source< ? > source )
{
final AffineTransform3D affineTransform3D = new AffineTransform3D();
source.getSourceTransform( 0, 0, affineTransform3D );
final FinalRealInterval bounds = affineTransform3D.estimateBounds( source.getSource( 0, 0 ) );
return bounds;
}
What do you think?
NicoKiaru commented
Looks good! I would add a timepoint parameter though