Short Description

Inversion of an ROI in python.

Versions

  • Version 1 • Released on: 2013-03-08 17:20:56
    Download
    Description:

    initial version

    # 
    # Inverse ROI: 
    # 	replaces the current ROI by its inverse.
    # 
    from icy.main import Icy
    from icy.roi import ROI2DRectangle
    from icy.roi import ROI2D
    from icy.util import ShapeUtil
    import sys
    
    seq = Icy.getMainInterface().getFocusedSequence()
    img = Icy.getMainInterface().getFocusedImage()
    
    if seq == None:
    	sys.exit("No sequence")
    
    # Get current ROI
    roi = seq.getSelectedROI2D()
    
    if roi == None:
    	sys.exit("No selected ROI")
    
    # Create an ROI of the size of the image
    roiImage = ROI2DRectangle(img.getBounds())
    
    # Do the XOR operation
    res = ROI2D.merge([roi, roiImage], ShapeUtil.ShapeOperation.XOR)
    
    # Compute inverse by XOR operation
    seq.addROI(res)
    

Leave a Review