示例#1
0
# Now use IJ1 RoiManager to display the detected regions
rm = get_roi_manager(new=True)

for label in region_labels:

    region = regions.getLabelRegion(label)

    # Get the center of mass of the region
    center = region.getCenterOfMass()
    x = center.getDoublePosition(0)
    y = center.getDoublePosition(1)

    roi = PointRoi(x, y)
    if center.numDimensions() >= 3:
        z = center.getDoublePosition(2)
        roi.setPosition(int(z))

    rm.addRoi(roi)

    # You can also iterate over the `data` pixel by LabelRegion

    cursor = region.localizingCursor()
    dataRA = data.randomAccess()
    while cursor.hasNext():
        cursor.fwd()
        dataRA.setPosition(cursor)

        x = cursor.getDoublePosition(0)
        y = cursor.getDoublePosition(1)

        # Pixel of `data`
# Now use IJ1 RoiManager to display the detected regions 
rm = get_roi_manager(new=True)

for label in region_labels:
  
    region = regions.getLabelRegion(label)

  	# Get the center of mass of the region
    center = region.getCenterOfMass()
    x = center.getDoublePosition(0)
    y = center.getDoublePosition(1)
  
    roi = PointRoi(x, y)
    if center.numDimensions() >= 3:
        z = center.getDoublePosition(2)
        roi.setPosition(int(z))
      
    rm.addRoi(roi)
 
    # You can also iterate over the `data` pixel by LabelRegion
 
    cursor = region.localizingCursor()
    dataRA = data.randomAccess()
    while cursor.hasNext():
        cursor.fwd()
        dataRA.setPosition(cursor)
     
        x = cursor.getDoublePosition(0)
        y = cursor.getDoublePosition(1)
 
        # Pixel of `data`
示例#3
0
    # Loop through all the peak that were found
    for peak in peaks:
        # Print the current coordinates
        print "peaks", peak.getDoublePosition(0), peak.getDoublePosition(
            1), peak.getDoublePosition(2)
        # Add the current peak to the Roi manager
        roi = PointRoi(
            peak.getDoublePosition(0) / cal.pixelWidth,
            peak.getDoublePosition(1) / cal.pixelHeight)
        oval = OvalRoi(
            int(
                peak.getDoublePosition(0) / cal.pixelWidth -
                0.5 * radius / cal.pixelWidth),
            int(
                peak.getDoublePosition(1) / cal.pixelHeight -
                0.5 * radius / cal.pixelHeight), radius / cal.pixelWidth,
            radius / cal.pixelHeight)
        oval.setColor(Color.RED)
        # Set the Z position of the peak otherwise the peaks are all set on the same slice
        oval.setPosition(
            int(round(peak.getDoublePosition(2) / cal.pixelDepth)) + 1)
        roi.setPosition(
            int(round(peak.getDoublePosition(2) / cal.pixelDepth)) + 1)
        overlay.add(oval)
        imp.setOverlay(overlay)
        imp.updateAndDraw()

        rm.addRoi(roi)

else:
    print "The detector could not process the data."