/** Populates plane by reference using {@link PlanarAccess} interface. */ @Override @SuppressWarnings("unchecked") public <T extends RealType<T>> void populatePlane(final Reader reader, final int imageIndex, final int planeIndex, final byte[] plane, final ImgPlus<T> planarImg, final SCIFIOConfig config) { final Metadata m = reader.getMetadata(); @SuppressWarnings("rawtypes") final PlanarAccess planarAccess = imgUtilService.getPlanarAccess(planarImg); final int pixelType = m.get(imageIndex).getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final boolean fp = FormatTools.isFloatingPoint(pixelType); final boolean little = m.get(imageIndex).isLittleEndian(); Object planeArray = Bytes.makeArray(plane, bpp, fp, little); if (planeArray == plane) { // array was returned by reference; make a copy final byte[] planeCopy = new byte[plane.length]; System.arraycopy(plane, 0, planeCopy, 0, plane.length); planeArray = planeCopy; } planarAccess.setPlane(planeIndex, imgUtilService.makeArray(planeArray)); }
/** * As {@link #saveImg(String, Img)} with configuration options. * * @param id * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public Metadata saveImg(final String id, final Img<?> img, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { return saveImg(id, utils().makeSCIFIOImgPlus(img), 0, config); }
public AbstractArrayLoader(final Reader reader, final ImageRegion subRegion) { this.reader = reader; this.subRegion = subRegion; reader.getContext().inject(this); final RealType<?> inputType = imgUtilityService.makeType(reader.getMetadata().get(0).getPixelType()); compatible = outputClass().isAssignableFrom(inputType.getClass()); }
@Override public void convertBytes( final CharAccess data, final byte[] bytes, final int planesRead ) { final ImageMetadata iMeta = reader().getMetadata().get( 0 ); if ( isCompatible() ) { final int offset = planesRead * bytes.length; final ByteBuffer bb = ByteBuffer.wrap( bytes ); bb.order( iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN ); for ( int k = offset; bb.hasRemaining(); ++k ) data.setValue( k, bb.getChar() ); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel( pixelType ); final int offset = planesRead * ( bytes.length / bpp ); for ( int index = 0; index < bytes.length / bpp; index++ ) { final char value = ( char ) utils().decodeWord( bytes, index * bpp, pixelType, iMeta.isLittleEndian() ); data.setValue( offset + index, value ); } } }
final PlanarAccess<?> planarAccess = utils().getPlanarAccess(imgPlus); @SuppressWarnings("rawtypes") final RealType inputType = utils().makeType(r.getMetadata().get(0).getPixelType()); final T outputType = imgPlus.firstElement(); final boolean compatibleTypes = utils().getArrayAccess(imgPlus) != null && compatibleTypes;
imgUtilService.getDimLengths(m, imageIndex, config); final long[] pos = new long[dimLengths.length]; imgUtilService.decodeWord(plane, index++, pixelType, little)); randomAccess.fwd(planeX); imgUtilService.decodeWord(plane, index++, pixelType, little));
utils().getConstrainedLengths(reader.getMetadata(), i(imageIndex), config); if (SCIFIOCellImgFactory.class.isAssignableFrom(imgFactory.getClass())) {
@Override public void convertBytes( final IntAccess data, final byte[] bytes, final int planesRead ) { final ImageMetadata iMeta = reader().getMetadata().get( 0 ); if ( isCompatible() ) { final int offset = planesRead * ( bytes.length / Integer.BYTES ); final ByteBuffer bb = ByteBuffer.wrap( bytes ); bb.order( iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN ); for ( int k = offset; bb.hasRemaining(); ++k ) data.setValue( k, bb.getInt() ); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel( pixelType ); final int offset = planesRead * ( bytes.length / bpp ); for ( int index = 0; index < bytes.length / bpp; index++ ) { final int value = ( int ) utils().decodeWord( bytes, index * bpp, pixelType, iMeta.isLittleEndian() ); data.setValue( offset + index, value ); } } }
final PlanarAccess<?> planarAccess = utils().getPlanarAccess(imgPlus); @SuppressWarnings("rawtypes") final RealType inputType = utils().makeType(r.getMetadata().get(0).getPixelType()); final T outputType = imgPlus.firstElement(); final boolean compatibleTypes = utils().getArrayAccess(imgPlus) != null && compatibleTypes;
imgUtilService.getDimLengths(m, imageIndex, config); final long[] pos = new long[dimLengths.length]; imgUtilService.decodeWord(plane, index++, pixelType, little)); randomAccess.fwd(planeX); imgUtilService.decodeWord(plane, index++, pixelType, little));
utils().getConstrainedLengths(reader.getMetadata(), i(imageIndex), config); if (SCIFIOCellImgFactory.class.isAssignableFrom(imgFactory.getClass())) {
@Override public void convertBytes( final ShortAccess data, final byte[] bytes, final int planesRead ) { final ImageMetadata iMeta = reader().getMetadata().get( 0 ); if ( isCompatible() ) { final int offset = planesRead * ( bytes.length / Short.BYTES ); final ByteBuffer bb = ByteBuffer.wrap( bytes ); bb.order( iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN ); for ( int k = offset; bb.hasRemaining(); ++k ) data.setValue( k, bb.getShort() ); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel( pixelType ); final int offset = planesRead * ( bytes.length / bpp ); for ( int index = 0; index < bytes.length / bpp; index++ ) { final short value = ( short ) utils().decodeWord( bytes, index * bpp, pixelType, iMeta.isLittleEndian() ); data.setValue( offset + index, value ); } } }
/** Populates plane by reference using {@link PlanarAccess} interface. */ @Override @SuppressWarnings("unchecked") public <T extends RealType<T>> void populatePlane(final Reader reader, final int imageIndex, final int planeIndex, final byte[] plane, final ImgPlus<T> planarImg, final SCIFIOConfig config) { final Metadata m = reader.getMetadata(); @SuppressWarnings("rawtypes") final PlanarAccess planarAccess = imgUtilService.getPlanarAccess(planarImg); final int pixelType = m.get(imageIndex).getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final boolean fp = FormatTools.isFloatingPoint(pixelType); final boolean little = m.get(imageIndex).isLittleEndian(); Object planeArray = Bytes.makeArray(plane, bpp, fp, little); if (planeArray == plane) { // array was returned by reference; make a copy final byte[] planeCopy = new byte[plane.length]; System.arraycopy(plane, 0, planeCopy, 0, plane.length); planeArray = planeCopy; } planarAccess.setPlane(planeIndex, imgUtilService.makeArray(planeArray)); }
public AbstractArrayLoader(final Reader reader, final ImageRegion subRegion) { this.reader = reader; this.subRegion = subRegion; reader.getContext().inject(this); final RealType<?> inputType = imgUtilityService.makeType(reader.getMetadata().get(0).getPixelType()); compatible = outputClass().isAssignableFrom(inputType.getClass()); }
/** * As {@link #saveImg(String, Img)} with configuration options. * * @param id * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public Metadata saveImg(final String id, final Img<?> img, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { return saveImg(id, utils().makeSCIFIOImgPlus(img), 0, config); }
@Override public void convertBytes( final LongAccess data, final byte[] bytes, final int planesRead ) { final ImageMetadata iMeta = reader().getMetadata().get( 0 ); if ( isCompatible() ) { final int offset = planesRead * ( bytes.length / Long.BYTES ); final ByteBuffer bb = ByteBuffer.wrap( bytes ); bb.order( iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN ); for ( int k = offset; bb.hasRemaining(); ++k ) data.setValue( k, bb.getLong() ); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel( pixelType ); final int offset = planesRead * ( bytes.length / bpp ); for ( int index = 0; index < bytes.length / bpp; index++ ) { final long value = ( long ) utils().decodeWord( bytes, index * bpp, pixelType, iMeta.isLittleEndian() ); data.setValue( offset + index, value ); } } }
@SuppressWarnings("rawtypes") private RealType getType(final Reader r) { return utils().makeType(r.getMetadata().get(0).getPixelType()); }
/** * As {@link #saveImg(Writer, Img)}, with configuration options. * * @param w * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public void saveImg(final Writer w, final Img<?> img, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { saveImg(w, utils().makeSCIFIOImgPlus(img), 0, config); }
@Override public void convertBytes( final FloatAccess data, final byte[] bytes, final int planesRead ) { final ImageMetadata iMeta = reader().getMetadata().get( 0 ); if ( isCompatible() ) { final int offset = planesRead * ( bytes.length / Float.BYTES ); final ByteBuffer bb = ByteBuffer.wrap( bytes ); bb.order( iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN ); for ( int k = offset; bb.hasRemaining(); ++k ) data.setValue( k, bb.getFloat() ); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel( pixelType ); final int offset = planesRead * ( bytes.length / bpp ); for ( int index = 0; index < bytes.length / bpp; index++ ) { final float value = ( float ) utils().decodeWord( bytes, index * bpp, pixelType, iMeta.isLittleEndian() ); data.setValue( offset + index, value ); } } }
@SuppressWarnings("rawtypes") private RealType getType(final Reader r) { return utils().makeType(r.getMetadata().get(0).getPixelType()); }