Define Region of Interest (ROI)

Define a region of interest of the image.

define_roi(img, shape, device, roi=None, roi_input='default', debug=None, adjust=False, x_adj=0, y_adj=0, w_adj=0, h_adj=0)

returns device, ROI contour, ROI hierarchy

Important Note: In order for downstream detection of objects within a region of interest to perform properly ROI must be completely contained within the image.

How to Adjust The ROI

- If -adjust is set to False, then the ROI is the full size of the image (Top)
- If you would like to adjust the ROI then it is in the context of the full size of the image (see example image, bottom)

Screenshot

from plantcv import plantcv as pcv

# Define region of interest in an image, there is a futher function 'ROI Objects' that allows 
# the user to define if you want to include objects partially inside ROI or if you want to do cut objects to ROI.
device, roi, roi_hierarchy = define_roi(img, 'rectangle', device, roi=None, roi_input='default', debug="print", adjust=True, x_adj=0, y_adj=0, w_adj=0, h_adj=-925)

Image with rectangular ROI

Screenshot

from plantcv import plantcv as pcv

# Define region of interest in an image, there is a futher function 'ROI Objects' that allows 
# the user to define if you want to include objects partially inside ROI or if you want to do cut objects to ROI.
device, roi, roi_hierarchy = define_roi(img, 'circle', device, roi=None, roi_input='default', debug="print", adjust=True, x_adj=0, y_adj=0, w_adj=0, h_adj=-925)

Image with circular ROI

Screenshot

from plantcv import plantcv as pcv

# Define region of interest in an image, there is a futher function 'ROI Objects' that allows
# the user to define if you want to include objects partially inside ROI or if you want to do cut objects to ROI.
device, roi, roi_hierarchy = define_roi(img, 'ellipse', device, roi=None, roi_input='default', debug="print", adjust=True, x_adj=0, y_adj=0, w_adj=0, h_adj=-925)

Image with elliptical ROI

Screenshot