Refine search
double getColorValue(Color color) { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || imp.getBitDepth()==24) return color.getRGB()&0xffffff; ImageProcessor ip = imp.getProcessor(); ip.setRoi(0,0,1,1); ip = ip.crop(); ip.setColor(color); ip.drawDot(0,0); return ip.getf(0,0); }
public FakeImageWindow(ImagePlus imp, ImageCanvas ic, Display display) { super(imp.getTitle()); this.display = display; ij = IJ.getInstance(); this.imp = imp; this.ic = ic; imp.setWindow(this); WindowManager.addWindow(this); }
/** Returns a list of the titles of all open images. */ public synchronized static String[] getImageTitles() { int[] list = getIDList(); if (list==null) return new String[0]; String[] titles = new String[list.length]; for (int i=0; i<list.length; i++) { ImagePlus img = getImage(list[i]); titles[i] = img.getTitle(); } return titles; }
public void destroy() { flush(); WindowManager.setTempCurrentImage(imp); // the FakeImagePlus WindowManager.removeWindow(fake_win); // the FakeImageWindow }
public void run( String args ) if ( IJ.versionLessThan( "1.37i" ) ) return; final ImagePlus imp = WindowManager.getCurrentImage(); if ( imp == null ) { System.err.println( "There are no images open" ); return; } final GenericDialog gd = new GenericDialog( "Test SIFT" ); gd.showDialog(); if ( gd.wasCanceled() ) return; SIFT.readFields( gd, p ); final ImageProcessor ip1 = imp.getProcessor().convertToFloat(); final ImageProcessor ip2 = imp.getProcessor().duplicate().convertToRGB(); drawSquare( ip2, new double[]{ f.location[ 0 ], f.location[ 1 ] }, p.fdSize * 4.0 * ( double )f.scale, ( double )f.orientation ); new ImagePlus( imp.getTitle() + " Features ", ip2 ).show();
ImageProcessor getFilter(int size) { int[] wList = WindowManager.getIDList(); if (wList==null || wList.length<2) { IJ.error("FFT", "A filter (as an open image) is required."); return null; ImagePlus imp = WindowManager.getImage(wList[i]); titles[i] = imp!=null?imp.getTitle():""; if (stackSize>1) processStack = gd.getNextBoolean(); ImagePlus filterImp = WindowManager.getImage(wList[filterIndex]); if (filterImp==imp) { IJ.error("FFT", "The filter cannot be the same as the image being filtered."); return null; if (filterImp.getStackSize()>1) { IJ.error("FFT", "The filter cannot be a stack."); return null; ImageProcessor filter = filterImp.getProcessor(); if (filter!=null && filter.getBitDepth()!=32) filter = filter.convertToByte(true); filter = resizeFilter(filter, size); return filter;
public void run(ImageProcessor ip) { imp = WindowManager.getCurrentImage(); if (imp==null) { IJ.noImage(); return; int stackSize = imp.getStackSize(); Roi roi = imp.getRoi(); int roiType = roi!=null?roi.getType():0; IJ.error("Radial Reslicer...", "Stack required"); return; IJ.error("Radial Reslicer...", "Line selection required"); return; long startTime = System.currentTimeMillis(); ImagePlus imp2 = null; rgb = imp.getType()==ImagePlus.COLOR_RGB; double min = ip.getMin(); double max = ip.getMax(); if (!rgb) imp2.getProcessor().setMinAndMax(min, max); imp2.show(); if (noRoi)
void showBrushDialog() { GenericDialog gd = new GenericDialog("Selection Brush"); gd.addCheckbox("Enable selection brush", ovalType==BRUSH_ROI); gd.addNumericField(" Size:", brushSize, 0, 4, "pixels"); gd.showDialog(); if (gd.wasCanceled()) return; if (gd.getNextBoolean()) ovalType = BRUSH_ROI; brushSize = (int)gd.getNextNumber(); if (brushSize<1) brushSize=1; repaintTool(OVAL); ImagePlus img = WindowManager.getCurrentImage(); Roi roi = img!=null?img.getRoi():null; if (roi!=null && roi.getType()==Roi.OVAL && ovalType==BRUSH_ROI) img.deleteRoi(); Prefs.set(BRUSH_SIZE, brushSize); }
IJ.error("No function available"); return; ImagePlus img = WindowManager.getCurrentImage(); if (img==null) { IJ.noImage(); return; if (img.getTitle().matches("y\\s=.*")) { //title looks like a fit function IJ.error("First select the image to be transformed"); return; int width = img.getWidth(); int height = img.getHeight(); int size = width*height; float[] data = new float[size]; for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { value = ip.getPixelValue(x,y); data[y*width+x] = (float)cf.f(p, value); ImageProcessor ip2 = new FloatProcessor(width, height, data, ip.getColorModel()); new ImagePlus(img.getTitle()+"-transformed", ip2).show();
@Override public void run(String arg) { GenericDialog gd = new GenericDialog("Raster Rigid Registration"); int[] wIDs = WindowManager.getIDList(); if(wIDs == null){ IJ.error("No images open"); return; } String[] titles = new String[wIDs.length]; for(int i=0;i<wIDs.length;i++) titles[i] = WindowManager.getImage(wIDs[i]).getTitle(); gd.addChoice("Template", titles, titles[0]); gd.addChoice("Model", titles, titles[0]); gd.showDialog(); if (gd.wasCanceled()) return; templ = WindowManager.getImage(gd.getNextChoice()); model = WindowManager.getImage(gd.getNextChoice()); register(); warp(model); warped.show(); }
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (!isDataFlavorSupported(flavor)) throw new UnsupportedFlavorException(flavor); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) { imp = flatten(imp); ImageProcessor ip; if (imp.isComposite()) { ip = new ColorProcessor(imp.getImage()); ip.setRoi(imp.getRoi()); } else ip = imp.getProcessor(); ip = ip.crop(); int w = ip.getWidth(); int h = ip.getHeight(); IJ.showStatus(w+"x"+h+ " image copied to system clipboard"); Image img = IJ.getInstance().createImage(w, h); Graphics g = img.getGraphics(); g.drawImage(ip.createImage(), 0, 0, null); g.dispose(); return img; } else { //IJ.noImage(); return null; } }
public void run(ImageProcessor ip) { int current = image.getCurrentSlice(); String[] images = openImages(); if(images.length == 0) { IJ.error("No other images open"); return; } GenericDialog gd = new GenericDialog("Insert stack"); gd.addChoice("Stack", images, images[0]); gd.addNumericField("Slice number", current, 0); gd.showDialog(); if(gd.wasCanceled()) return; int slice = (int)gd.getNextNumber(); ImagePlus src = WindowManager.getImage(gd.getNextChoice()); insertStack(image, slice, src); }
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(); }
public void applySurfaceColors(final Content c) { if (!checkSel(c)) return; final int t = c.getType(); if (t != ContentConstants.SURFACE && t != ContentConstants.CUSTOM) return; final GenericDialog gd = new GenericDialog("Apply color from image"); final int[] ids = WindowManager.getIDList(); final String[] titles = new String[ids.length]; for (int i = 0; i < ids.length; i++) titles[i] = WindowManager.getImage(ids[i]).getTitle(); gd.addChoice("Color image", titles, titles[0]); gd.addCheckbox("Apply to all timepoints", true); gd.showDialog(); if (gd.wasCanceled()) return; final ImagePlus colorImage = WindowManager.getImage(gd.getNextChoice()); if (gd.getNextBoolean()) c.applySurfaceColors(colorImage); else if (c.getCurrent() != null) c.getCurrent().applySurfaceColors( colorImage); }
public void run(String arg) { IJ.log("Starting plugin Graph Cut"); // read image imp = WindowManager.getCurrentImage(); if (imp == null) { IJ.showMessage("Please open an image first."); return; } int channels = imp.getNChannels(); if (channels > 1) { int channel = 0; while (channel <= 0 || channel > channels) channel = (int)IJ.getNumber("Please give the number of the channel you wish to consider for the segmentation (1 - " + channels + "):", 1); imp = extractChannel(imp, channel); } // start GUI displayImage = new ImagePlus(); displayImage.setProcessor("Graph Cut", imp.getProcessor().duplicate()); IJ.log("Starting GUI..."); SwingUtilities.invokeLater( new Runnable() { public void run() { IJ.log("Creating window..."); win = new GraphCutWindow(displayImage); win.pack(); } }); }
public void openRoi(String dir, String name) throws IOException { String path = dir+name; RoiDecoder rd = new RoiDecoder(path); Roi roi = rd.getRoi(); Rectangle r = roi.getBounds(); ImagePlus img = WindowManager.getCurrentImage(); if (img==null || img.getWidth()<(r.x+r.width) || img.getHeight()<(r.y+r.height)) { ImageProcessor ip = new ByteProcessor(r.x+r.width+10, r.y+r.height+10); img = new ImagePlus(name, ip); img.show(); } img.setRoi(roi); }
public static String getAverageCIELAB() { Average_Color t = new Average_Color(); try { t.image = WindowManager.getCurrentImage(); t.pixels = (int[])t.image.getProcessor().getPixels(); t.w = t.image.getWidth(); t.h = t.image.getHeight(); Roi roi = t.image.getRoi(); if (roi == null) roi = new Roi(0, 0, t.w, t.h); float[] result = t.getAverageColor(roi, true); return "" + result[0] + " " + result[1] + " " + result[2]; } catch (Exception e) { return ""; } }
/** Overrides PlugInFrame.close(). */ public void close() { super.close(); instance = null; resetMultiMeasureResults(); Prefs.saveLocation(LOC_KEY, getLocation()); if (!showAllCheckbox.getState() || IJ.macroRunning()) return; int n = getCount(); ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null || (imp.getCanvas()!=null && imp.getCanvas().getShowAllList()==null)) return; if (n>0) { GenericDialog gd = new GenericDialog("ROI Manager"); gd.addMessage("Save the "+n+" displayed ROIs as an overlay?"); gd.setOKLabel("Discard"); gd.setCancelLabel("Save as Overlay"); gd.showDialog(); if (gd.wasCanceled()) moveRoisToOverlay(imp); else removeOverlay(imp); } else imp.draw(); }
@Override public void run(ImageProcessor ip) { GenericDialog gd = new GenericDialog("Transform Parameters"); AmiraParameters.addAmiraMeshList(gd, "imageToTransform"); gd.addStringField("origPoints", ""); gd.addStringField("transPoints", ""); gd.showDialog(); if (gd.wasCanceled()) return; ImagePlus trans = WindowManager.getImage(gd.getNextChoice()); Point3d[] origPoints = parsePoints(gd.getNextString()); Point3d[] transPoints = parsePoints(gd.getNextString()); ElasticTransformedImage t = new ElasticTransformedImage(new InterpolatedImage(image), new InterpolatedImage(trans), origPoints, transPoints); t.getTransformed().image.show(); }