private ImagePlus makeComposite(ImagePlus imp, FileInfo fi) { int c = imp.getNChannels(); boolean composite = c>1 && fi.description!=null && fi.description.indexOf("mode=")!=-1; if (c>1 && (imp.getOpenAsHyperStack()||composite) && !imp.isComposite() && imp.getType()!=ImagePlus.COLOR_RGB) { int mode = IJ.COLOR; if (fi.description!=null) { if (fi.description.indexOf("mode=composite")!=-1) mode = IJ.COMPOSITE; else if (fi.description.indexOf("mode=gray")!=-1) mode = IJ.GRAYSCALE; } imp = new CompositeImage(imp, mode); } return imp; }
public void resetDisplayRange() { if (getType()==GRAY16 && getDefault16bitRange()!=0) { int defaultRange = getDefault16bitRange(); for (int i=1; i<=getNChannels(); i++) { LUT lut = getChannelLut(i); lut.min = 0; lut.max = Math.pow(2,defaultRange)-1; if (getWindow()!=null) setChannelLut(lut, i); } } else { ip.resetMinAndMax(); int c = getChannelIndex(); lut[c].min = ip.getMin(); lut[c].max = ip.getMax(); } }
/** Copies the LUTs and display mode of 'imp' to this image. Does nothing if 'imp' is not a CompositeImage or 'imp' and this image do not have the same number of channels. */ public synchronized void copyLuts(ImagePlus imp) { int channels = getNChannels(); if (!imp.isComposite() || imp.getNChannels()!=channels) return; CompositeImage ci = (CompositeImage)imp; LUT[] luts = ci.getLuts(); if (luts!=null && luts.length==channels) { lut = luts; cip = null; } int mode2 = ci.getMode(); setMode(mode2); if (mode2==COMPOSITE) { boolean[] active2 = ci.getActiveChannels(); for (int i=0; i<MAX_CHANNELS; i++) active[i] = active2[i]; } if (ci.hasCustomLuts()) customLuts = true; }
public void reset() { int nChannels = getNChannels(); if (nChannels>MAX_CHANNELS && getMode()==COMPOSITE) setMode(COLOR); setup(nChannels, getImageStack()); }
int getChannelIndex() { int channels = getNChannels(); if (lut==null) setupLuts(channels); int index = getChannel()-1; return index; }
public void setLuts(LUT[] luts) { int channels = getNChannels(); if (lut==null) setupLuts(channels); if (luts==null || luts.length<channels) throw new IllegalArgumentException("Lut array is null or too small"); for (int i=0; i<channels; i++) setChannelLut(luts[i], i+1); }
notYetComposite.setDimensions( 2, 1, seq.getSize() - 1 ); impFlowVectors = new CompositeImage( notYetComposite, CompositeImage.GRAYSCALE ); impFlowVectors.setOpenAsHyperStack( true ); impFlowVectors.setDimensions( 2, 1, seq.getSize() - 1 ); impFlowVectors.show(); impFlowVectors.setPosition( 1, 1, 1 ); impFlowVectors.setDisplayRange( 0, 1 ); impFlowVectors.setPosition( 2, 1, 1 ); impFlowVectors.setDisplayRange( -Math.PI, Math.PI ); impFlowVectors.setPosition( 1, 1, i ); imp.setSlice( i + 1 );
if (imp2!=imp) { if (imp.isComposite()) { imp2 = new CompositeImage(imp2, ((CompositeImage)imp).getMode()); ((CompositeImage)imp2).copyLuts(imp); } else imp2.setLut(imp.getProcessor().getLut());
if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; if (ci.getMode()!=IJ.COMPOSITE) { ci.setMode(IJ.COMPOSITE); ci.updateAndDraw(); } else { if (arg!=null && arg.equals("color")) ((CompositeImage)imp2).setMode(IJ.COLOR); imp2.setZ(slice); imp.close(); if (gd.wasCanceled()) return; int index = gd.getNextChoiceIndex(); CompositeImage ci = new CompositeImage(imp, index+1); if (imp.getBitDepth()!=8) { ci.reset(); ci.resetDisplayRanges(); if (IJ.isMacro()) IJ.wait(250); ci.show(); } else IJ.error("To create a composite, the current image must be\n a stack with at least 2 channels or be in RGB format.");
final CompositeImage newcimp = new CompositeImage(newimp,cimp.getMode()); newcimp.copyLuts(cimp); if (!RJ_Options.adopt) { final int nc = newcimp.getNChannels(); for (int c=1; c<=nc; ++c) { final LUT lut = newcimp.getChannelLut(c); lut.min = min; lut.max = max;
imp2.setDimensions(lastC-firstC+1, lastZ-firstZ+1, lastT-firstT+1); if (imp.isComposite()) { int mode = ((CompositeImage)imp).getMode(); if (lastC>firstC) { imp2 = new CompositeImage(imp2, mode); int i2 = 1; for (int i=firstC; i<=lastC; i++) { LUT lut = ((CompositeImage)imp).getChannelLut(i); ((CompositeImage)imp2).setChannelLut(lut, i2++); LUT lut = ((CompositeImage)imp).getChannelLut(firstC); imp2.getProcessor().setColorModel(lut); imp2.setDisplayRange(lut.min, lut.max);
img3.setDimensions(dim[2], dim[3], dim[4]); if (img1.isComposite()) { img3 = new CompositeImage(img3, 0); ((CompositeImage)img3).copyLuts(img1);
projImage.setDimensions(channels, 1, frames); if (channels>1) { projImage = new CompositeImage(projImage, 0); ((CompositeImage)projImage).copyLuts(imp); if (method==SUM_METHOD || method==SD_METHOD) ((CompositeImage)projImage).resetDisplayRanges();
this.ci = new CompositeImage( tmp, CompositeImage.COMPOSITE ); this.ci.setDimensions( 1, (int)this.psi.dimension( 2 ), 1 ); this.ci.setDisplayMode( IJ.GRAYSCALE ); this.ci.show(); for ( int i = 0; i < this.psi.dimension( 2 ); ++i ) this.stack.addSlice( "Iteration 2", t.getProcessor( i + 1 ) ); this.ci.hide(); this.ci = new CompositeImage( new ImagePlus( "debug view", this.stack ), CompositeImage.COMPOSITE ); this.ci.setDimensions( 1, (int)this.psi.dimension( 2 ), 2 ); this.ci.setDisplayMode( IJ.GRAYSCALE ); this.ci.show(); this.stack.addSlice( "Iteration " + i, t.getProcessor( i + 1 ) ); this.ci.setStack( this.stack, 1, (int)this.psi.dimension( 2 ), stack.getSize() / (int)this.psi.dimension( 2 ) );
imp.setCalibration(cal); imp.setDimensions(3, nSlices, 1); CompositeImage ci = new CompositeImage(imp, IJ.GRAYSCALE); ci.show(); imp.hide();
newImp.setCalibration( imp.getCalibration() ); final CompositeImage c = new CompositeImage( newImp, CompositeImage.COMPOSITE ); if (targetChannels == 0) //if channels stay channels c.setLuts(imp.getLuts()); c.show();
/** Returns the display mode (IJ.COMPOSITE, IJ.COLOR or IJ.GRAYSCALE) if this is a composite color image, or 0 if it not. */ public int getDisplayMode() { if (this instanceof CompositeImage) return ((CompositeImage)this).getMode(); else return 0; }
void invertLut() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) {IJ.noImage(); return;} if (imp.getType()==ImagePlus.COLOR_RGB) {IJ.error("RGB images do not use LUTs"); return;} if (imp.isComposite()) { CompositeImage ci = (CompositeImage)imp; LUT lut = ci.getChannelLut(); if (lut!=null) ci.setChannelLut(lut.createInvertedLut()); } else { ImageProcessor ip = imp.getProcessor(); ip.invertLut(); if (imp.getStackSize()>1) imp.getStack().setColorModel(ip.getColorModel()); } imp.updateAndRepaintWindow(); }
/** Tester for composite (multi-channel) images. */ private void test(int pixelType, boolean autoscale, boolean crop, double calib, double min1, double max1, double min2, double max2, double min3, double max3) { final ImagePlus imp = setup(pixelType, autoscale, crop, calib, 3); final CompositeImage ci = (CompositeImage) imp; final LUT lut1 = ci.getChannelLut(1); final LUT lut2 = ci.getChannelLut(2); final LUT lut3 = ci.getChannelLut(3); assertEquals(min1 - calib, lut1.min, 0.0); assertEquals(max1 - calib, lut1.max, 0.0); assertEquals(min2 - calib, lut2.min, 0.0); assertEquals(max2 - calib, lut2.max, 0.0); assertEquals(min3 - calib, lut3.min, 0.0); assertEquals(max3 - calib, lut3.max, 0.0); }
protected void transferChannelSettings( final CompositeImage ci, final SetupAssignments setupAssignments, final VisibilityAndGrouping visibility ) { final int nChannels = ci.getNChannels(); final int mode = ci.getCompositeMode(); final boolean transferColor = mode == IJ.COMPOSITE || mode == IJ.COLOR; for ( int c = 0; c < nChannels; ++c ) { final LUT lut = ci.getChannelLut( c + 1 ); final ConverterSetup setup = setupAssignments.getConverterSetups().get( c ); if ( transferColor ) setup.setColor( new ARGBType( lut.getRGB( 255 ) ) ); setup.setDisplayRange( lut.min, lut.max ); } if ( mode == IJ.COMPOSITE ) { final boolean[] activeChannels = ci.getActiveChannels(); visibility.setDisplayMode( DisplayMode.FUSED ); for ( int i = 0; i < activeChannels.length; ++i ) visibility.setSourceActive( i, activeChannels[ i ] ); } else visibility.setDisplayMode( DisplayMode.SINGLE ); visibility.setCurrentSource( ci.getChannel() - 1 ); }