@@ -97,7 +97,7 @@ public static enum DISTANCE_TYPE
9797 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
9898 * transforms of sampled functions</a> on source using squared Euclidian
9999 * (L2) or L1 distance. Intermediate and final results will be stored in
100- * source (@{ link DoubleType} recommended). The distance can be weighted
100+ * source ({@ link DoubleType} recommended). The distance can be weighted
101101 * (individually for each dimension, if desired) against the image values
102102 * via the weights parameter.
103103 *
@@ -123,7 +123,7 @@ public static < T extends RealType< T > > void transform(
123123 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
124124 * transforms of sampled functions</a> on source using squared Euclidian
125125 * (L2) or L1 distance. Intermediate and final results will be stored in
126- * source (@{ link DoubleType} recommended). The distance can be weighted
126+ * source ({@ link DoubleType} recommended). The distance can be weighted
127127 * (individually for each dimension, if desired) against the image values
128128 * via the weights parameter.
129129 *
@@ -157,7 +157,7 @@ public static < T extends RealType< T > > void transform(
157157 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
158158 * transforms of sampled functions</a> on source using squared Euclidian
159159 * (L2) or L1 distance. Intermediate results will be stored in target
160- * (@{ link DoubleType} recommended). The distance can be weighted
160+ * ({@ link DoubleType} recommended). The distance can be weighted
161161 * (individually for each dimension, if desired) against the image values
162162 * via the weights parameter.
163163 *
@@ -186,7 +186,7 @@ public static < T extends RealType< T >, U extends RealType< U > > void transfor
186186 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
187187 * transforms of sampled functions</a> on source using squared Euclidian
188188 * (L2) or L1 distance. Intermediate results will be stored in target
189- * (@{ link DoubleType} recommended). The distance can be weighted
189+ * ({@ link DoubleType} recommended). The distance can be weighted
190190 * (individually for each dimension, if desired) against the image values
191191 * via the weights parameter.
192192 *
@@ -222,10 +222,10 @@ public static < T extends RealType< T >, U extends RealType< U > > void transfor
222222 * Create
223223 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
224224 * transforms of sampled functions</a> on source using squared Euclidian
225- * (L2) or L1 distance. Intermediate results will be stored in tmp (@{link
226- * DoubleType} recommended). The output will be written into target. The
227- * distance can be weighted (individually for each dimension, if desired)
228- * against the image values via the weights parameter.
225+ * (L2) or L1 distance. Intermediate results will be stored in tmp
226+ * ({@link DoubleType} recommended). The output will be written into target.
227+ * The distance can be weighted (individually for each dimension, if
228+ * desired) against the image values via the weights parameter.
229229 *
230230 * @param source
231231 * Input function on which distance transform should be computed.
@@ -268,10 +268,10 @@ public static < T extends RealType< T >, U extends RealType< U >, V extends Real
268268 * Create
269269 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
270270 * transforms of sampled functions</a> on source using squared Euclidian
271- * (L2) or L1 distance. Intermediate results will be stored in tmp (@{link
272- * DoubleType} recommended). The output will be written into target. The
273- * distance can be weighted (individually for each dimension, if desired)
274- * against the image values via the weights parameter.
271+ * (L2) or L1 distance. Intermediate results will be stored in tmp
272+ * ({@link DoubleType} recommended). The output will be written into target.
273+ * The distance can be weighted (individually for each dimension, if
274+ * desired) against the image values via the weights parameter.
275275 *
276276 * @param source
277277 * Input function on which distance transform should be computed.
@@ -323,7 +323,7 @@ public static < T extends RealType< T >, U extends RealType< U >, V extends Real
323323 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
324324 * transforms of sampled functions</a> on source using arbitrary
325325 * {@link Distance} d. Intermediate and final results will be stored in
326- * source (@{ link DoubleType} recommended).
326+ * source ({@ link DoubleType} recommended).
327327 *
328328 * @param source
329329 * Input function on which distance transform should be computed.
@@ -342,7 +342,7 @@ public static < T extends RealType< T > > void transform(
342342 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
343343 * transforms of sampled functions</a> on source using arbitrary
344344 * {@link Distance} d. Intermediate and final results will be stored in
345- * source (@{ link DoubleType} recommended).
345+ * source ({@ link DoubleType} recommended).
346346 *
347347 * @param source
348348 * Input function on which distance transform should be computed.
@@ -369,7 +369,7 @@ public static < T extends RealType< T > > void transform(
369369 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
370370 * transforms of sampled functions</a> on source using arbitrary
371371 * {@link Distance} d. Intermediate and final results will be stored in
372- * target (@{ link DoubleType} recommended).
372+ * target ({@ link DoubleType} recommended).
373373 *
374374 * @param source
375375 * Input function on which distance transform should be computed.
@@ -391,7 +391,7 @@ public static < T extends RealType< T >, U extends RealType< U > > void transfor
391391 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
392392 * transforms of sampled functions</a> on source using arbitrary
393393 * {@link Distance} d. Intermediate and final results will be stored in
394- * target (@{ link DoubleType} recommended).
394+ * target ({@ link DoubleType} recommended).
395395 *
396396 * @param source
397397 * Input function on which distance transform should be computed.
@@ -418,8 +418,8 @@ public static < T extends RealType< T >, U extends RealType< U > > void transfor
418418 * Create
419419 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
420420 * transforms of sampled functions</a> on source using arbitrary
421- * {@link Distance} d. Intermediate results will be stored in tmp (@{link
422- * DoubleType} recommended). The output will be written into target.
421+ * {@link Distance} d. Intermediate results will be stored in tmp
422+ * ({@link DoubleType} recommended). The output will be written into target.
423423 *
424424 * @param source
425425 * Input function on which distance transform should be computed.
@@ -442,27 +442,37 @@ public static < T extends RealType< T >, U extends RealType< U >, V extends Real
442442 final int lastDim = nDim - 1 ;
443443
444444 if ( nDim == 1 )
445+ {
445446 transformAlongDimension (
446447 ( RandomAccessible < T > ) Views .addDimension ( source ),
447448 Views .interval ( Views .addDimension ( target ), new FinalInterval ( target .dimension ( 0 ), 1 ) ),
448449 d ,
449450 0 );
451+ }
450452 else
453+ {
451454 transformAlongDimension ( source , tmp , d , 0 );
455+ }
452456
453457 for ( int dim = 1 ; dim < nDim ; ++dim )
458+ {
454459 if ( dim == lastDim )
460+ {
455461 transformAlongDimension ( tmp , target , d , dim );
462+ }
456463 else
464+ {
457465 transformAlongDimension ( tmp , tmp , d , dim );
466+ }
467+ }
458468 }
459469
460470 /**
461471 * Create
462472 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
463473 * transforms of sampled functions</a> on source using arbitrary
464- * {@link Distance} d. Intermediate results will be stored in tmp (@{link
465- * DoubleType} recommended). The output will be written into target.
474+ * {@link Distance} d. Intermediate results will be stored in tmp
475+ * ({@link DoubleType} recommended). The output will be written into target.
466476 *
467477 * @param source
468478 * Input function on which distance transform should be computed.
@@ -524,7 +534,7 @@ public static < T extends RealType< T >, U extends RealType< U >, V extends Real
524534 * Create
525535 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
526536 * transforms of sampled functions</a> on source using L1 distance.
527- * Intermediate results will be stored in tmp (@{ link DoubleType}
537+ * Intermediate results will be stored in tmp ({@ link DoubleType}
528538 * recommended). The output will be written into target. The distance can be
529539 * weighted (individually for each dimension, if desired) against the image
530540 * values via the weights parameter.
@@ -550,26 +560,36 @@ private static < T extends RealType< T >, U extends RealType< U >, V extends Rea
550560 final int lastDim = nDim - 1 ;
551561
552562 if ( nDim == 1 )
563+ {
553564 transformL1AlongDimension (
554565 ( RandomAccessible < T > ) Views .addDimension ( source ),
555566 Views .interval ( Views .addDimension ( target ), new FinalInterval ( target .dimension ( 0 ), 1 ) ),
556567 0 ,
557568 weights [ 0 ] );
569+ }
558570 else
571+ {
559572 transformL1AlongDimension ( source , tmp , 0 , weights [ 0 ] );
573+ }
560574
561575 for ( int dim = 1 ; dim < nDim ; ++dim )
576+ {
562577 if ( dim == lastDim )
578+ {
563579 transformL1AlongDimension ( tmp , target , dim , weights [ dim ] );
580+ }
564581 else
582+ {
565583 transformL1AlongDimension ( tmp , tmp , dim , weights [ dim ] );
584+ }
585+ }
566586 }
567587
568588 /**
569589 * Create
570590 * <a href="http://www.theoryofcomputing.org/articles/v008a019/">distance
571591 * transforms of sampled functions</a> on source using L1 distance.
572- * Intermediate results will be stored in tmp (@{ link DoubleType}
592+ * Intermediate results will be stored in tmp ({@ link DoubleType}
573593 * recommended). The output will be written into target. The distance can be
574594 * weighted (individually for each dimension, if desired) against the image
575595 * values via the weights parameter.
@@ -603,21 +623,31 @@ private static < T extends RealType< T >, U extends RealType< U >, V extends Rea
603623 final int lastDim = nDim - 1 ;
604624
605625 if ( nDim == 1 )
626+ {
606627 transformL1AlongDimensionParallel (
607628 ( RandomAccessible < T > ) Views .addDimension ( source ),
608629 Views .interval ( Views .addDimension ( target ), new FinalInterval ( target .dimension ( 0 ), 1 ) ),
609630 0 ,
610631 weights [ 0 ],
611632 es ,
612633 nTasks );
634+ }
613635 else
636+ {
614637 transformL1AlongDimensionParallel ( source , tmp , 0 , weights [ 0 ], es , nTasks );
638+ }
615639
616640 for ( int dim = 1 ; dim < nDim ; ++dim )
641+ {
617642 if ( dim == lastDim )
643+ {
618644 transformL1AlongDimensionParallel ( tmp , target , dim , weights [ dim ], es , nTasks );
645+ }
619646 else
647+ {
620648 transformL1AlongDimensionParallel ( tmp , tmp , dim , weights [ dim ], es , nTasks );
649+ }
650+ }
621651 }
622652
623653 private static < T extends RealType < T >, U extends RealType < U > > void transformAlongDimension (
@@ -640,7 +670,9 @@ private static < T extends RealType< T >, U extends RealType< U > > void transfo
640670 final RealComposite < T > sourceComp = s .next ();
641671 final RealComposite < U > targetComp = t .next ();
642672 for ( long i = 0 ; i < size ; ++i )
673+ {
643674 tmp .get ( i ).set ( sourceComp .get ( i ).getRealDouble () );
675+ }
644676 transformSingleColumn ( tmp , targetComp , lowerBoundDistanceIndex , envelopeIntersectLocation , d , dim , size );
645677 }
646678 }
@@ -656,7 +688,9 @@ private static < T extends RealType< T >, U extends RealType< U > > void transfo
656688 int largestDim = getLargestDimension ( Views .hyperSlice ( target , dim , target .min ( dim ) ) );
657689 // ignore dimension along which we calculate transform
658690 if ( largestDim >= dim )
691+ {
659692 largestDim += 1 ;
693+ }
660694 final long size = target .dimension ( dim );
661695 final long stepPerChunk = Math .max ( size / nTasks , 1 );
662696
@@ -718,7 +752,9 @@ private static < T extends RealType< T >, U extends RealType< U > > void transfo
718752 for ( long position = 0 ; position < size ; ++position )
719753 {
720754 while ( envelopeIntersectLocation .get ( k + 1 ).get () < position )
755+ {
721756 ++k ;
757+ }
722758 final long envelopeIndexAtK = lowerBoundDistanceIndex .get ( k ).get ();
723759 // copy necessary because of the following line, access to source
724760 // after write to source -> source and target cannot be the same
@@ -745,7 +781,9 @@ private static < T extends RealType< T >, U extends RealType< U > > void transfo
745781 final RealComposite < T > sourceComp = s .next ();
746782 final RealComposite < U > targetComp = t .next ();
747783 for ( long i = 0 ; i < size ; ++i )
784+ {
748785 tmp .get ( i ).set ( sourceComp .get ( i ).getRealDouble () );
786+ }
749787 transformL1SingleColumn ( tmp , targetComp , weight , size );
750788 }
751789 }
@@ -761,7 +799,9 @@ private static < T extends RealType< T >, U extends RealType< U > > void transfo
761799 int largestDim = getLargestDimension ( Views .hyperSlice ( target , dim , target .min ( dim ) ) );
762800 // ignore dimension along which we calculate transform
763801 if ( largestDim >= dim )
802+ {
764803 largestDim += 1 ;
804+ }
765805 final long size = target .dimension ( dim );
766806 final long stepPerChunk = Math .max ( size / nTasks , 1 );
767807
@@ -819,7 +859,9 @@ private static < T > void invokeAllAndWait( final ExecutorService es, final Coll
819859 {
820860 final List < Future < T > > futures = es .invokeAll ( tasks );
821861 for ( final Future < T > f : futures )
862+ {
822863 f .get ();
864+ }
823865 }
824866
825867 /**
0 commit comments