/** Constructs an ImageConverter based on an ImagePlus object. */ public ImageConverter(ImagePlus imp) { this.imp = imp; type = imp.getType(); }
public static boolean okForGif(ImagePlus imp) { if (imp.getType()==ImagePlus.COLOR_RGB) return false; else return true; }
public void loadGCT8bit(ImagePlus image){ int type = image.getType(); if (!(((type == 0) ||( type == 3))&&(image!=null))) throw new IllegalArgumentException("Color Table Image must be 8 bit"); gctused = true; GCTloadedExternal = true; gct = null; Process8bitCLT(image); } /*
/** Save the image in JPEG format using the specified path. @see #setJpegQuality @see #getJpegQuality */ public boolean saveAsJpeg(String path) { String err = JpegWriter.save(imp, path, jpegQuality); if (err==null && !(imp.getType()==ImagePlus.GRAY16 || imp.getType()==ImagePlus.GRAY32)) updateImp(fi, FileInfo.GIF_OR_JPG); return true; }
void setMinAndMax(ImagePlus imp, double min, double max) { boolean rgb = imp.getType()==ImagePlus.COLOR_RGB; if (channels!=7 && rgb) imp.setDisplayRange(min, max, channels); else imp.setDisplayRange(min, max); }
@Override boolean save(final ImagePlus imp, final String path) { return ImageSaver.saveAsJpeg(imp.getProcessor(), path, q, ImagePlus.COLOR_RGB != imp.getType()); } }
public StackConverter(ImagePlus imp) { this.imp = imp; type = imp.getType(); nSlices = imp.getStackSize(); if (nSlices<2) throw new IllegalArgumentException("Stack required"); width = imp.getWidth(); height = imp.getHeight(); }
/** Save the current LUT using a save file dialog. Returns false if the user selects cancel. */ public boolean saveAsLut() { if (imp.getType()==ImagePlus.COLOR_RGB) { error("RGB Images do not have a LUT."); return false; } String path = getPath("LUT", ".lut"); if (path==null) return false; return saveAsLut(path); }
/** Returns the size of this image in bytes. */ public double getSizeInBytes() { double size = ((double)getWidth()*getHeight()*getStackSize()); int type = getType(); switch (type) { case ImagePlus.GRAY16: size *= 2.0; break; case ImagePlus.GRAY32: size *= 4.0; break; case ImagePlus.COLOR_RGB: size *= 4.0; break; } return size; }
public static ByteImagePlus<UnsignedByteType> wrapByte( final ImagePlus imp ) { if ( imp.getType() != ImagePlus.GRAY8) return null; final ByteImagePlus< UnsignedByteType > container = new ByteImagePlus< UnsignedByteType >( imp ); // create a Type that is linked to the container final UnsignedByteType linkedType = new UnsignedByteType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; }
public static IntImagePlus<ARGBType> wrapRGBA( final ImagePlus imp ) { if ( imp.getType() != ImagePlus.COLOR_RGB) return null; final IntImagePlus< ARGBType > container = new IntImagePlus< ARGBType >( imp ); // create a Type that is linked to the container final ARGBType linkedType = new ARGBType( container ); // pass it to the DirectAccessContainer container.setLinkedType( linkedType ); return container; }
public static FloatImagePlus<FloatType> wrapFloat( final ImagePlus imp ) { if ( imp.getType() != ImagePlus.GRAY32) return null; final FloatImagePlus<FloatType> container = new FloatImagePlus<FloatType>( imp ); // create a Type that is linked to the container final FloatType linkedType = new FloatType( container ); // pass it to the DirectAccessContainer container.setLinkedType( linkedType ); return container; }
public static ShortImagePlus<UnsignedShortType> wrapShort( final ImagePlus imp ) { if ( imp.getType() != ImagePlus.GRAY16) return null; final ShortImagePlus< UnsignedShortType > container = new ShortImagePlus< UnsignedShortType >( imp ); // create a Type that is linked to the container final UnsignedShortType linkedType = new UnsignedShortType( container ); // pass it to the DirectAccessContainer container.setLinkedType( linkedType ); return container; }
public void extractGCTrgb(ImagePlus image){ if((image== null)||(4!=image.getType())) throw new IllegalArgumentException("Color Table Image must be RGB"); packrgb(image); gctused = true; GCTextracted = true; GCTloadedExternal =true; gct = null; OverRideQuality(image.getWidth()*image.getHeight()); analyzePixels(); // build color table pixels = null; }
@Override final protected void init() { ipOriginal = imp.getProcessor(); if ( imp.getType() == ImagePlus.GRAY32 ) fp = ( FloatProcessor )ipOriginal.duplicate(); else fp = ( FloatProcessor )ipOriginal.convertToFloat(); imp.setProcessor( fp ); std = new BlockStatistics( fp ); }
private Dataset makeDataset(ImagePlus imp) { ImgPlus imgPlus = toImgPlus(imp); final Dataset ds = datasetService.create( imgPlus ); DatasetUtils.initColorTables(ds); ds.setRGBMerged( imp.getType() == ImagePlus.COLOR_RGB && imp.getNChannels() == 1); return ds; }
@Override final protected void init() { ipOriginal = imp.getProcessor(); if ( imp.getType() == ImagePlus.GRAY32 ) fp = ( FloatProcessor )ipOriginal.duplicate(); else fp = ( FloatProcessor )ipOriginal.convertToFloat(); imp.setProcessor( fp ); variance = new BlockStatistics( fp ); }
public static void convert(final ImagePlus image) { final int imaget = image.getType(); if (imaget == ImagePlus.GRAY8 || imaget == ImagePlus.COLOR_256) return; final int s = image.getStackSize(); switch (imaget) { case ImagePlus.GRAY16: case ImagePlus.GRAY32: if (s == 1) new ImageConverter(image).convertToGray8(); else new StackConverter(image).convertToGray8(); break; } }
public static ImagePlusImgLoader< UnsignedShortType > createGray32( final ImagePlus imp, final MinMaxOption minMaxOption, final double min, final double max ) { if( imp.getType() != ImagePlus.GRAY32 ) throw new RuntimeException( "expected ImagePlus type GRAY32" ); if ( imp.getStack() != null && imp.getStack().isVirtual() ) return new ImagePlusImgLoader<>( imp, VirtualStackImageLoader.createFloatInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); else return new ImagePlusImgLoader<>( imp, ImageStackImageLoader.createFloatInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); }
public static ImagePlusImgLoader< FloatType > createFloatFromGray8( final ImagePlus imp, final MinMaxOption minMaxOption, final double min, final double max ) { if( imp.getType() != ImagePlus.GRAY8 ) throw new RuntimeException( "expected ImagePlus type GRAY8" ); if ( imp.getStack() != null && imp.getStack().isVirtual() ) return new ImagePlusImgLoader<>( imp, VirtualStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new FloatType(), new RealFloatConverterFactory() ); else return new ImagePlusImgLoader<>( imp, ImageStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new FloatType(), new RealFloatConverterFactory() ); }