use of org.janelia.intensity.LinearIntensityMap in project TrakEM2 by trakem2.
the class FSLoader method mapIntensities.
@SuppressWarnings("unchecked")
@Override
protected boolean mapIntensities(final Patch p, final ImagePlus imp) {
final ImagePlus coefficients = new Opener().openImage(getUNUIdFolder() + "trakem2.its/" + createIdPath(Long.toString(p.getId()), "it", ".tif"));
if (coefficients == null)
return false;
final ImageProcessor ip = imp.getProcessor();
@SuppressWarnings({ "rawtypes" }) final LinearIntensityMap<FloatType> map = new LinearIntensityMap<FloatType>((FloatImagePlus) ImagePlusImgs.from(coefficients));
@SuppressWarnings("rawtypes") Img img;
final long[] dims = new long[] { imp.getWidth(), imp.getHeight() };
switch(p.getType()) {
case ImagePlus.GRAY8:
case // this only works for continuous color tables
ImagePlus.COLOR_256:
img = ArrayImgs.unsignedBytes((byte[]) ip.getPixels(), dims);
break;
case ImagePlus.GRAY16:
img = ArrayImgs.unsignedShorts((short[]) ip.getPixels(), dims);
break;
case ImagePlus.COLOR_RGB:
img = ArrayImgs.argbs((int[]) ip.getPixels(), dims);
break;
case ImagePlus.GRAY32:
img = ArrayImgs.floats((float[]) ip.getPixels(), dims);
break;
default:
img = null;
}
if (img == null)
return false;
map.run(img);
return true;
}
Aggregations