MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / createMask

Method createMask

ij/src/main/java/ij/plugin/Selection.java:612–654  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

610 }*/
611
612 void createMask(ImagePlus imp) {
613 Roi roi = imp.getRoi();
614 boolean useInvertingLut = Prefs.useInvertingLut;
615 Prefs.useInvertingLut = false;
616 boolean selectAll = roi!=null && roi.getType()==Roi.RECTANGLE && roi.getBounds().width==imp.getWidth()
617 && roi.getBounds().height==imp.getHeight() && imp.isThreshold();
618 boolean overlay = imp.getOverlay()!=null && !imp.isThreshold();
619 if (!overlay && (roi==null || selectAll)) {
620 createMaskFromThreshold(imp);
621 Prefs.useInvertingLut = useInvertingLut;
622 return;
623 }
624 if (roi==null && imp.getOverlay()==null) {
625 IJ.error("Create Mask", "Selection, overlay or threshold required");
626 return;
627 }
628 ByteProcessor mask = imp.createRoiMask();
629 if (!Prefs.blackBackground)
630 mask.invertLut();
631 mask.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE);
632 ImagePlus maskImp = null;
633 Frame frame = WindowManager.getFrame("Mask");
634 if (frame!=null && (frame instanceof ImageWindow))
635 maskImp = ((ImageWindow)frame).getImagePlus();
636 if (maskImp!=null && maskImp.getBitDepth()==8) {
637 ImageProcessor ip = maskImp.getProcessor();
638 ip.copyBits(mask, 0, 0, Blitter.OR);
639 maskImp.setProcessor(ip);
640 } else {
641 maskImp = new ImagePlus("Mask", mask);
642 maskImp.show();
643 }
644 Calibration cal = imp.getCalibration();
645 if (cal.scaled()) {
646 Calibration cal2 = maskImp.getCalibration();
647 cal2.pixelWidth = cal.pixelWidth;
648 cal2.pixelHeight = cal.pixelHeight;
649 cal2.setUnit(cal.getUnit());
650 }
651 maskImp.updateAndRepaintWindow();
652 Prefs.useInvertingLut = useInvertingLut;
653 Recorder.recordCall("mask = imp.createRoiMask();");
654 }
655
656 void createMaskFromThreshold(ImagePlus imp) {
657 ImageProcessor ip = imp.getProcessor();

Callers 1

runMethod · 0.95

Calls 15

getTypeMethod · 0.95
getBoundsMethod · 0.95
errorMethod · 0.95
setThresholdMethod · 0.95
getFrameMethod · 0.95
getBitDepthMethod · 0.95
getProcessorMethod · 0.95
copyBitsMethod · 0.95
setProcessorMethod · 0.95
showMethod · 0.95
getCalibrationMethod · 0.95

Tested by

no test coverage detected