Skip to content

Commit

Permalink
ExportARGB.makeFlatImageARGBFromOriginals: works correctly,
Browse files Browse the repository at this point in the history
by using the new TransformMeshMappingWithMasks for ColorProcessor.
  • Loading branch information
acardona committed Mar 27, 2018
1 parent 032809b commit e76ae24
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions TrakEM2_/src/main/java/mpicbg/trakem2/transform/ExportARGB.java
Expand Up @@ -143,34 +143,27 @@ static public final Pair< ColorProcessor, ByteProcessor > makeFlatImageARGBFromO
final ColorProcessor target = new ColorProcessor((int)(roi.width * scale), (int)(roi.height * scale));
target.setInterpolationMethod( ImageProcessor.BILINEAR );
final ByteProcessor targetMask = new ByteProcessor( target.getWidth(), target.getHeight() );
targetMask.setInterpolationMethod( ImageProcessor.BILINEAR );
final ByteProcessor outsideMask = new ByteProcessor( target.getWidth(), target.getHeight() );
outsideMask.setInterpolationMethod( ImageProcessor.BILINEAR );
final ImageProcessorWithMasks targets = new ImageProcessorWithMasks( target, targetMask, outsideMask );
targetMask.setInterpolationMethod( ImageProcessor.NEAREST_NEIGHBOR );

for (final Patch patch : patches) {
final Patch.PatchImage pai = patch.createTransformedImage();
final ColorProcessor fp = (ColorProcessor) pai.target.convertToRGB();
final ByteProcessor alpha;
final ByteProcessor outside;

System.out.println("IMAGE:" + patch.getTitle());
System.out.println("mask: " + pai.mask);
System.out.println("outside: " + pai.outside);

if ( null == pai.mask ) {
alpha = new ByteProcessor( fp.getWidth(), fp.getHeight() );
Arrays.fill( ( byte[] )alpha.getPixels(), (byte)255 ); // fully opaque
if ( null == pai.outside ) {
alpha = new ByteProcessor( fp.getWidth(), fp.getHeight() );
Arrays.fill( ( byte[] )alpha.getPixels(), (byte)255 ); // fully opaque
} else {
alpha = pai.outside;
}
} else {
alpha = pai.mask;
}

if ( null == pai.outside ) {
outside = new ByteProcessor( fp.getWidth(), fp.getHeight() );
Arrays.fill( ( byte[] )outside.getPixels(), (byte)0 ); // fully transparent
} else {
outside = pai.outside;
}

// The affine to apply
final AffineTransform atc = new AffineTransform();
Expand All @@ -190,7 +183,7 @@ static public final Pair< ColorProcessor, ByteProcessor > makeFlatImageARGBFromO
fp.setInterpolationMethod( ImageProcessor.BILINEAR );
alpha.setInterpolationMethod( ImageProcessor.NEAREST_NEIGHBOR ); // no interpolation

mapping.mapInterpolated( new ImageProcessorWithMasks( fp, alpha, outside ), targets );
mapping.map( fp, alpha, target, targetMask );
}

return new Pair< ColorProcessor, ByteProcessor >( target, targetMask );
Expand Down

0 comments on commit e76ae24

Please sign in to comment.