ij.gui.PointRoi Java Examples

The following examples show how to use ij.gui.PointRoi. 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: PointMatchClientTest.java    From render with GNU General Public License v2.0 6 votes vote down vote up
private static void showMatches(final String imageUrl,
                                final List<CanvasMatches> canvasMatchesList,
                                final boolean isP,
                                final Color[] colors) {

    final ImagePlus imagePlus = IJ.openImage(imageUrl);
    final Overlay overlay = new Overlay();

    int colorIndex = 0;
    for (final CanvasMatches canvasMatches : canvasMatchesList) {
        final double[][] points = isP ? canvasMatches.getMatches().getPs() : canvasMatches.getMatches().getQs();
        final float[] xPoints = toFloat(points[0]);
        final float[] yPoints = toFloat(points[1]);
        final PointRoi pointRoi = new PointRoi(xPoints, yPoints, xPoints.length);
        pointRoi.setStrokeColor(colors[colorIndex]);
        pointRoi.setSize(3); // 0: "Tiny", 1: "Small", 2: "Medium", 3: "Large", 4: "Extra Large"}
        overlay.add(pointRoi);
        colorIndex = (colorIndex + 1) % colors.length;
    }

    imagePlus.setOverlay(overlay);
    imagePlus.updateAndDraw();
    imagePlus.show();

}
 
Example #2
Source File: MatPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 6 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    Mat m =(Mat)o;
    opencv_core.MatVector xy = new opencv_core.MatVector(2);
    split(m, xy);
    int h = m.rows();
    int[] xpoints = new int[h];
    int[] ypoints = new int[h];

    for (int i = 0; i < h; i++) {
        xpoints[i] = xy.get(0).getIntBuffer().get(i);
        ypoints[i] = xy.get(1).getIntBuffer().get(i);
    }

    PointRoi pr = new PointRoi(xpoints, ypoints, h);
    return (T)pr;
}
 
Example #3
Source File: KeyPointVectorPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    KeyPointVector pv = (opencv_core.KeyPointVector)o;
    float[] xpoints = new float[(int) pv.size()];
    float[] ypoints = new float[(int) pv.size()];

    for (int i = 0; i < (int) pv.size(); i++) {
        xpoints[i] = (float) pv.get(i).pt().x();
        ypoints[i] = (float) pv.get(i).pt().y();
    }
    PointRoi pr = new PointRoi(xpoints, ypoints);
    return (T)pr;
}
 
Example #4
Source File: Point2dVectorPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    opencv_core.Point2dVector pv = (opencv_core.Point2dVector)o;
    float[] xpoints = new float[(int) pv.size()];
    float[] ypoints = new float[(int) pv.size()];

    for (int i = 0; i < (int) pv.size(); i++) {
        xpoints[i] = (float) pv.get(i).x();
        ypoints[i] = (float) pv.get(i).y();
    }
    PointRoi pr = new PointRoi(xpoints, ypoints);
    return(T) pr;

}
 
Example #5
Source File: PointVectorPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    opencv_core.PointVector pv = (opencv_core.PointVector)o;
    float[] xpoints = new float[(int) pv.size()];
    float[] ypoints = new float[(int) pv.size()];

    for (int i = 0; i < (int) pv.size(); i++) {
        xpoints[i] = (float) pv.get(i).x();
        ypoints[i] = (float) pv.get(i).y();
    }
    PointRoi pr = new PointRoi(xpoints, ypoints);
    return(T) pr;
}
 
Example #6
Source File: PointRoiPoint2fVectorConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
     PointRoi pr = (PointRoi)o; 
    
    int[] xpoints = pr.getPolygon().xpoints;
    int[] ypoints = pr.getPolygon().ypoints;
    opencv_core.Point2fVector pv = new opencv_core.Point2fVector(xpoints.length);
    for (int i = 0; i < xpoints.length; i++) {
        pv.put(i, new opencv_core.Point2f(xpoints[i], ypoints[i]));
    }
    return (T)pv;
}
 
Example #7
Source File: KeyPointDetectorJ_.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {

    GenericDialog gd = new GenericDialog("Select Keypoint detector");
    gd.addChoice("Method", methods, method);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    method = gd.getNextChoice();
    PointRoi res = keyPointDetection(method);
    imp.setRoi(res);

}
 
Example #8
Source File: PointRoiPoint2dVectorConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi) o;

    int[] xpoints = pr.getPolygon().xpoints;
    int[] ypoints = pr.getPolygon().ypoints;
    opencv_core.Point2dVector pv = new opencv_core.Point2dVector(xpoints.length);
    for (int i = 0; i < xpoints.length; i++) {
        pv.put(i, new opencv_core.Point2d(xpoints[i], ypoints[i]));
    }
    return (T) pv;

}
 
Example #9
Source File: PointRoiKeyPointVectorConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi) o;

    int[] xpoints = pr.getPolygon().xpoints;
    int[] ypoints = pr.getPolygon().ypoints;
    KeyPointVector pv = new KeyPointVector(xpoints.length);
    for (int i = 0; i < xpoints.length; i++) {
        pv.put(i, new opencv_core.KeyPoint(xpoints[i], ypoints[i], 1));
    }
    return (T) pv;
}
 
Example #10
Source File: PointRoiPoint2dConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canConvert(Object src, Type dest) {
    if (!(src instanceof PointRoi)) {
        return false;
    }
    PointRoi pr = (PointRoi) src;
    if (pr.getType() != Roi.POINT) {
        return false;
    }
    return true;
}
 
Example #11
Source File: Point2fVectorPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
opencv_core.Point2fVector pv = (opencv_core.Point2fVector)o;
    float[] xpoints = new float[(int) pv.size()];
    float[] ypoints = new float[(int) pv.size()];

    for (int i = 0; i < (int) pv.size(); i++) {
        xpoints[i] = (float) pv.get(i).x();
        ypoints[i] = (float) pv.get(i).y();
    }
    PointRoi pr = new PointRoi(xpoints, ypoints);
    return(T) pr;

}
 
Example #12
Source File: PointRoiPoint2dConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi) o;
    opencv_core.Point2d p = new opencv_core.Point2d(pr.getXCoordinates()[0], pr.getYCoordinates()[0]);
    return (T) p;

}
 
Example #13
Source File: PointRoiKeyPointConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canConvert(Object src, Type dest) {
    if(!(src instanceof PointRoi)){
        return false;
    }
    PointRoi pr =(PointRoi)src;
    if (pr.getType() != Roi.POINT) {
        return false;
    }
    return true;
}
 
Example #14
Source File: PointRoiKeyPointConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi)o;
    opencv_core.KeyPoint p = new KeyPoint(pr.getXCoordinates()[0], pr.getYCoordinates()[0], 1);
    return(T) p;

}
 
Example #15
Source File: PointRoiPoint2fConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi) o;
    opencv_core.Point2f p = new opencv_core.Point2f(pr.getXCoordinates()[0], pr.getYCoordinates()[0]);
    return (T) p;

}
 
Example #16
Source File: PointRoiPoint2fConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canConvert(Object src, Type dest) {
    if (!(src instanceof PointRoi)) {
        return false;
    }
    PointRoi pr = (PointRoi) src;
    if (pr.getType() != Roi.POINT) {
        return false;
    }
    return true;
}
 
Example #17
Source File: PointRoiPointVectorConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi) o;

    int[] xpoints = pr.getPolygon().xpoints;
    int[] ypoints = pr.getPolygon().ypoints;
    opencv_core.PointVector pv = new opencv_core.PointVector(xpoints.length);
    for (int i = 0; i < xpoints.length; i++) {
        pv.put(i, new opencv_core.Point(xpoints[i], ypoints[i]));
    }
    return (T) pv;
}
 
Example #18
Source File: PointRoiPointConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr = (PointRoi) o;
    opencv_core.Point p = new opencv_core.Point(pr.getXCoordinates()[0], pr.getYCoordinates()[0]);
    return (T) p;

}
 
Example #19
Source File: PointRoiPointConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canConvert(Object src, Type dest) {
    if (!(src instanceof PointRoi)) {
        return false;
    }
    PointRoi pr = (PointRoi) src;
    if (pr.getType() != Roi.POINT) {
        return false;
    }
    return true;
}
 
Example #20
Source File: PointRoiMatConverter.java    From IJ-OpenCV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    PointRoi pr =(PointRoi)o; 
    int[] xpoints = pr.getPolygon().xpoints;
    int[] ypoints = pr.getPolygon().ypoints;
    Mat mx = new Mat(xpoints);
    Mat my = new Mat(ypoints);
    opencv_core.MatVector mxy = new opencv_core.MatVector(2);
    mxy.put(0, mx);
    mxy.put(1, my);
    Mat m = new Mat();
    merge(mxy, m);
    return (T)m;
}
 
Example #21
Source File: MatPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getOutputType() {
    return PointRoi.class;
}
 
Example #22
Source File: PointPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getOutputType() {
    return PointRoi.class;
}
 
Example #23
Source File: KeyPointPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    KeyPoint p = (KeyPoint)o;
    PointRoi pr = new PointRoi(p.pt().x(), p.pt().y());
    return (T)pr;
}
 
Example #24
Source File: PointPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    opencv_core.Point p =(opencv_core.Point)o;
    PointRoi pr = new PointRoi(p.x(), p.y());
    return (T)pr;
}
 
Example #25
Source File: Point2fPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getOutputType() {
    return PointRoi.class;
}
 
Example #26
Source File: Point2fPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public < T> T convert(Object o, Class< T> type) {
    opencv_core.Point2f p =(opencv_core.Point2f)o;
    PointRoi pr = new PointRoi(p.x(), p.y());
    return (T)pr;
}
 
Example #27
Source File: KeyPointPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getOutputType() {
    return PointRoi.class;
}
 
Example #28
Source File: KeyPointVectorPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getOutputType() {
    return PointRoi.class;
}
 
Example #29
Source File: Point2fVectorPointRoiConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getOutputType() {
    return PointRoi.class;
}
 
Example #30
Source File: PointRoiPoint2dVectorConverter.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class< PointRoi> getInputType() {
    return PointRoi.class;
}