/** * This method draws the rectangle * @param imp the ImagePlus on to which to draw the bounds */ public void drawBounds(ImagePlus imp){ double w = x1-x0+1; double h = y1-y0+1; boolean isLocked = imp.isLocked(); if (isLocked == true) {imp.unlock();} IJ.run("Specify...", "width="+ Math.round(w)+ " height="+ Math.round(h)+ " x="+ Math.round(x0)+ " y="+ Math.round(y0)); IJ.run("Draw"); if (isLocked == true) {imp.lock();} if (bverbose){ IJ.log("w="+w+" h="+h+" x="+ x0+" y="+y0); } }
/** * This method will draw the center of the box * @param imp the ImagePlus onto which to draw the center */ public void drawCenter(ImagePlus imp){ double c[] = getCenter(); boolean isLocked = imp.isLocked(); if (isLocked == true) {imp.unlock();} IJ.setTool(Toolbar.POINT); IJ.makePoint( (int) Math.round(c[0]), (int) Math.round(c[1])); IJ.run("Draw"); if (isLocked == true) {imp.lock();} }
if(!imp.lock()) return; // exit if in use
imp.lock(); else
imp.lock(); else
void del() { if (!imp.lock()) return; ImageStack stack = imp.getStack(); int n = imp.getCurrentSlice(); stack.deleteSlice(n); if (stack.getSize()==1) { imp.setProcessor(null, stack.getProcessor(1)); new ImageWindow(imp); } imp.setStack(null, stack); numSlices--; if (n>numSlices) imp.setSlice(numSlices); else imp.setSlice(n); imp.unlock(); } void delN(){
if(!imp.lock()) return; // exit if in use processStack(imp,numSubStacks);
public void run(String arg) { imp = WindowManager.getCurrentImage(); if (imp!=null) { if (imp.isComposite() && arg.equals("RGB Color") && !imp.getStack().isRGB() && !imp.getStack().isHSB() && !imp.getStack().isLab()) { if (imp.getWindow()==null && !ij.macro.Interpreter.isBatchMode()) RGBStackConverter.convertToRGB(imp); else { (new RGBStackConverter()).run(""); imp.setTitle(imp.getTitle()); // updates size in Window menu } } else if (imp.lock()) { convert(arg); imp.unlock(); imp.setTitle(imp.getTitle()); } else IJ.log("<<Converter: image is locked ("+imp+")>>"); } else IJ.noImage(); }
void deleteSlice() { if (nSlices<2) {IJ.error("\"Delete Slice\" requires a stack"); return;} if (imp.isHyperStack() || (imp.isComposite() && nSlices==imp.getNChannels())) { deleteHyperstackChannelSliceOrFrame(); return; } if (!imp.lock()) return; ImageStack stack = imp.getStack(); int n = imp.getCurrentSlice(); stack.deleteSlice(n); if (stack.getSize()==1) { String label = stack.getSliceLabel(1); if (label!=null) imp.setProperty("Label", label); } imp.setStack(null, stack); if (n--<1) n = 1; imp.setSlice(n); imp.unlock(); imp.changes = true; }
public void run(String arg) { imp = WindowManager.getCurrentImage(); if (imp!=null) { if (imp.isComposite() && arg.equals("RGB Color") && !imp.getStack().isRGB() && !imp.getStack().isHSB() && !imp.getStack().isLab()) { if (imp.getWindow()==null && !ij.macro.Interpreter.isBatchMode()) RGBStackConverter.convertToRGB(imp); else { (new RGBStackConverter()).run(""); imp.setTitle(imp.getTitle()); // updates size in Window menu } } else if (imp.lock()) { convert(arg); imp.unlock(); imp.setTitle(imp.getTitle()); } else IJ.log("<<Converter: image is locked ("+imp+")>>"); } else IJ.noImage(); }
void addSlice() { if (imp.isHyperStack() || imp.isComposite()) { addHyperstackChannelSliceOrFrame(); return; } if (!imp.lock()) return; int id = 0; ImageStack stack = imp.getStack(); if (stack.getSize()==1) { String label = stack.getSliceLabel(1); if (label!=null && label.indexOf("\n")!=-1) stack.setSliceLabel(null, 1); Object obj = imp.getProperty("Label"); if (obj!=null && (obj instanceof String)) stack.setSliceLabel((String)obj, 1); id = imp.getID(); } ImageProcessor ip = imp.getProcessor(); int n = imp.getCurrentSlice(); if (IJ.altKeyDown()) n--; // insert in front of current slice stack.addSlice(null, ip.createProcessor(width, height), n); imp.setStack(null, stack); imp.setSlice(n+1); imp.unlock(); imp.changes = true; if (id!=0) IJ.selectWindow(id); // prevents macros from failing }
@Override final public void run() imp.lock();
void addSlice() { if (imp.isHyperStack() || imp.isComposite()) { addHyperstackChannelSliceOrFrame(); return; } if (!imp.lock()) return; int id = 0; ImageStack stack = imp.getStack(); if (stack.getSize()==1) { String label = stack.getSliceLabel(1); if (label!=null && label.indexOf("\n")!=-1) stack.setSliceLabel(null, 1); Object obj = imp.getProperty("Label"); if (obj!=null && (obj instanceof String)) stack.setSliceLabel((String)obj, 1); id = imp.getID(); } ImageProcessor ip = imp.getProcessor(); int n = imp.getCurrentSlice(); if (IJ.altKeyDown()) n--; // insert in front of current slice stack.addSlice(null, ip.createProcessor(width, height), n); imp.setStack(null, stack); imp.setSlice(n+1); imp.unlock(); imp.changes = true; if (id!=0) IJ.selectWindow(id); // prevents macros from failing }
void deleteSlice() { if (nSlices<2) {IJ.error("\"Delete Slice\" requires a stack"); return;} if (imp.isHyperStack() || (imp.isComposite() && nSlices==imp.getNChannels())) { deleteHyperstackChannelSliceOrFrame(); return; } if (!imp.lock()) return; ImageStack stack = imp.getStack(); int n = imp.getCurrentSlice(); stack.deleteSlice(n); if (stack.getSize()==1) { String label = stack.getSliceLabel(1); if (label!=null) imp.setProperty("Label", label); } imp.setStack(null, stack); if (n--<1) n = 1; imp.setSlice(n); imp.unlock(); imp.changes = true; }
@Override final public void run() imp.lock();
if (gd.wasCanceled()) return; if (!imp.lock()) return; // exit if in use long tstart = System.currentTimeMillis(); gd.setSmartRecording(true);
return; if (!imp.lock()) { return;
return; if (!imp.lock()) return; Undo.reset();
return; if (!imp.lock()) return; Undo.reset();
if(!imp.lock())return; // exit if in use