Java Code Examples for ij.plugin.frame.RoiManager#setVisible()
The following examples show how to use
ij.plugin.frame.RoiManager#setVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FaceDetectionJ_.java From IJ-OpenCV with GNU General Public License v3.0 | 6 votes |
@Override public void run() { //Converters RectRoiConverter rc = new RectRoiConverter(); opencv_core.Mat img2 = ImagePlusMatConverter.toMat(imp, 8); // also does RGB to Gray automatically // Detect the faces and store them as an array of rectangles opencv_core.RectVector rv = detectFaces(img2); // Add rectangles to ROI Manager RoiManager rm = new RoiManager(); rm.setVisible(true); for (int i = 0; i < rv.size(); i++) { Roi r = rc.convert(rv.get(i), Roi.class); rm.add(imp, r, 0); } //Show all ROI rm.runCommand("Show All"); }
Example 2
Source File: HoughLinesJ_.java From IJ-OpenCV with GNU General Public License v3.0 | 5 votes |
@Override public void run() { // Do line detection ArrayList<Line> linesIJ = HoughLines(imp, min_length, step_line, min_theta, max_theta, step_theta); // Add lines to RoiManager RoiManager rm = new RoiManager(); rm.setVisible(true); for (int i = 0; i < linesIJ.size(); i++) { rm.add(imp, linesIJ.get(i), i); } }
Example 3
Source File: TemplateMatchingJ_.java From IJ-OpenCV with GNU General Public License v3.0 | 4 votes |
@Override public void run() { ImagePlus original = (ImagePlus) imp.clone(); Roi r = imp.getRoi(); if (r == null) { IJ.error("Select a rectangle first"); return; } if (r.isArea() && (r.getType() == Roi.RECTANGLE)) { // Crop the selection to be the template IJ.run(imp, "Crop", ""); //Converters ImagePlusMatConverter ic = new ImagePlusMatConverter(); RectRoiConverter rc = new RectRoiConverter(); // Convert the ImageJ images to OpenCV images opencv_core.Mat matching = ic.convert(original, Mat.class); opencv_core.Mat template = ic.convert(imp, Mat.class); opencv_core.Mat gray = new opencv_core.Mat(); opencv_imgproc.cvtColor(matching, gray, opencv_imgproc.COLOR_BGR2GRAY); opencv_imgproc.cvtColor(template, template, opencv_imgproc.COLOR_BGR2GRAY); opencv_core.Mat results = new opencv_core.Mat(); // Matching and normalisation matchTemplate(gray, template, results, TM_CCOEFF_NORMED); normalize(results, results, 0, 1, NORM_MINMAX, -1, new opencv_core.Mat()); DoublePointer minVal = new DoublePointer(); DoublePointer maxVal= new DoublePointer(); opencv_core.Point minLoc = new opencv_core.Point(); opencv_core.Point maxLoc = new opencv_core.Point(); opencv_core.Point matchLoc; minMaxLoc(results, minVal, maxVal, minLoc, maxLoc, new opencv_core.Mat()); ArrayList<opencv_core.Point> locations = obtainLocations(results, 0.99, template.cols(), template.rows()); RoiManager rm = new RoiManager(); rm.setVisible(true); opencv_core.Rect solution; Roi solutionIJ; opencv_core.Point p; for (int i = 0; i < locations.size(); i++) { p = locations.get(i); solution = new opencv_core.Rect(p.x(), p.y(), template.cols(), template.rows()); solutionIJ = rc.convert(solution, Roi.class); rm.add(original, solutionIJ, i); } imp.changes = false; imp.close(); original.show(); } else { IJ.error("Select a rectangle"); } }
Example 4
Source File: FindContoursJ_.java From IJ-OpenCV with GNU General Public License v3.0 | 3 votes |
@Override public void run() { // Converters ImagePlusMatConverter ic = new ImagePlusMatConverter(); opencv_core.Mat m = ic.convert(imp,opencv_core.Mat.class); MatVectorListPolygonRoiConverter pc = new MatVectorListPolygonRoiConverter(); opencv_core.Mat gray = new opencv_core.Mat(); opencv_imgproc.cvtColor(m,gray,opencv_imgproc.COLOR_BGR2GRAY); MatVector contours = new opencv_core.MatVector(); opencv_imgproc.findContours(gray,contours,opencv_imgproc.RETR_LIST,opencv_imgproc.CHAIN_APPROX_SIMPLE); ArrayList<PolygonRoi> contoursROI = new ArrayList<PolygonRoi>(); contoursROI= pc.convert(contours,contoursROI.getClass()); // Add rectangles to ROI Manager RoiManager rm = new RoiManager(); rm.setVisible(true); for (PolygonRoi contoursROI1 : contoursROI) { rm.add(imp, contoursROI1, 0); } }