/** * Represent an arbitrary RandomAccessibleInterval as an Img * * @param accessible * RandomAccessibleInterval which will be wrapped with an ImgView * @param factory * ImgFactory returned by {@link ImgView#factory()} * @return * RandomAccessibleInterval represented as an Img */ public static < T extends Type< T >> Img< T > wrap(final RandomAccessibleInterval< T > accessible, final ImgFactory< T > factory){ if(accessible instanceof Img){ return (Img<T>) accessible; }else{ return new ImgView< T >(accessible, factory); } } }
/** * Represent an arbitrary RandomAccessibleInterval as an Img * * @param accessible * RandomAccessibleInterval which will be wrapped with an ImgView * @param factory * ImgFactory returned by {@link ImgView#factory()} * @return * RandomAccessibleInterval represented as an Img */ public static < T extends Type< T >> Img< T > wrap(final RandomAccessibleInterval< T > accessible, final ImgFactory< T > factory){ if(accessible instanceof Img){ return (Img<T>) accessible; }else{ return new ImgView< T >(accessible, factory); } } }
private static <T extends Type<T>> Img<T> setUpSlice( ImgPlus<T> sourceImgPlus, int d, long pos) { return new ImgView<T>(Views.hyperSlice(sourceImgPlus, d, pos), sourceImgPlus.factory()); }
private static <T extends Type<T>> Img<T> setUpSlice( ImgPlus<T> sourceImgPlus, int d, long pos) { return new ImgView<T>(Views.hyperSlice(sourceImgPlus, d, pos), sourceImgPlus.factory()); }
new ImgView<>( Converters.convert( ( RandomAccessibleInterval<UnsignedByteType> ) ImageJFunctions.wrapByte( imp ),
@SuppressWarnings("unused") private Overlay createDefaultOverlay(final Roi roi) { final Rectangle bounds = roi.getBounds(); final ArrayImg<BitType, LongArray> arrayImg = ArrayImgs.bits(bounds.width, bounds.height); arrayImg.setLinkedType(new BitType(arrayImg)); final int xOff = bounds.x; final int yOff = bounds.y; final Img<BitType> img = new ImgView<BitType>(Views.translate(arrayImg, xOff, yOff), arrayImg .factory()); final RandomAccess<BitType> ra = img.randomAccess(); final ImageProcessor ip = roi.getMask(); for (int i = xOff; i < xOff + bounds.width; i++) { ra.setPosition(i, 0); for (int j = yOff; j < yOff + bounds.height; j++) { ra.setPosition(j, 1); ra.get().set(ip.get(i - xOff, j - yOff) > 0); } } final BinaryMaskRegionOfInterest<BitType, Img<BitType>> broi = new BinaryMaskRegionOfInterest<BitType, Img<BitType>>(img); final Overlay overlay = new BinaryMaskOverlay<BitType, Img<BitType>>(getContext(), broi); assignPropertiesToOverlay(overlay, roi); return overlay; }