Example #1
0
def get_polygons_from_rois(conn, image):
    """ 
    Returns a list of (x, y, width, height), one for each ROI with rectangle shape

    @param conn:        BlitzGateway connection
    @param imageId:     Image ID
    """

    # Using the underlying ROI service & omero.model objects (no ROI support in Blitz Gateway yet)
    roiService = conn.getRoiService()
    imageId = image.getId()
    result = roiService.findByImage(imageId, None)
    updateService = conn.getUpdateService()
    polygons = []
    rects = []
    for roi in result.rois:
        # go through all the shapes of the ROI
        roi_id = roi.getId().getValue()
        for shape in roi.copyShapes():
            if shape.__class__.__name__ == 'PolygonI':
                poly = PolygonData(shape)
                rect = poly.getBoundingRectangle()
                points = poly.fromPoints("points")
                print 'points', type(points)
                print 'rect', rect
                x = rect[0][0]
                y = rect[0][1]
                w = rect[1][0] - rect[0][0]
                h = rect[1][1] - rect[0][1]
                rects.append((x, y, w, h, roi_id))
                polygons.append(poly)
                break

    return rects, polygons
def get_polygons_from_rois(conn, image):
    """ 
    Returns a list of (x, y, width, height), one for each ROI with rectangle shape

    @param conn:        BlitzGateway connection
    @param imageId:     Image ID
    """

    # Using the underlying ROI service & omero.model objects (no ROI support in Blitz Gateway yet)
    roiService = conn.getRoiService()
    imageId = image.getId()
    result = roiService.findByImage(imageId, None)
    updateService = conn.getUpdateService()
    polygons = []
    rects = []
    for roi in result.rois:
        # go through all the shapes of the ROI
        roi_id = roi.getId().getValue()
        for shape in roi.copyShapes():
            if shape.__class__.__name__ == 'PolygonI':
                poly = PolygonData(shape)
                rect = poly.getBoundingRectangle()
                points = poly.fromPoints("points")
                print 'points',type(points)
                print 'rect',rect
                x = rect[0][0]
                y = rect[0][1]
                w = rect[1][0] - rect[0][0]
                h = rect[1][1] - rect[0][1] 
                rects.append( (x,y,w,h,roi_id) )
                polygons.append(poly)
                break

    return rects,polygons