Roi

Roi#

class Roi(roiName, options)#

Bases: handle

Region of Interest (ROI) management for image processing.

Provides functionality for defining, manipulating, and applying regions of interest to image data. Supports rotation, sub-ROI creation, and coordinate transformations between different coordinate systems.

Example1:

% Create ROI from configuration
roi = Roi("CenterRegion", imageSize=[1024, 1024]);
roiData = roi.select(imageData);

Example2:

% Create custom ROI with rotation
roi = Roi(yxBoundary=[100, 500, 200, 600], angle=45);
roi.rotate(30);
subRoiData = roi.selectSub(imageData);
Constructor Summary
Roi(roiName, options)#

Constructor for Roi class.

Parameters:
  • roiName (string, optional) – Name of ROI configuration to load

  • yxBoundary (uint32, optional) – ROI boundaries [Y1,Y2,X1,X2]

  • angle (double, optional) – Rotation angle in degrees

  • centerSize (double, optional) – ROI center and size [centerY,centerX,sizeY,sizeX]

  • imageSize (uint32, optional) – Image dimensions [height,width]

  • subRoiCenterSize (double, optional) – Sub-ROI specifications

  • subRoiNRowColumn (double, optional) – Sub-ROI grid dimensions

  • subRoiSeparation (double, optional) – Sub-ROI separation distances

  • isSubRoi (logical, optional) – Whether this is a sub-ROI

Example:

roi = Roi("CenterRegion");
roi = Roi(yxBoundary=[100, 500, 200, 600], angle=45);
roi = Roi(centerSize=[256, 256, 100, 100], imageSize=[512, 512]);
Property Summary
Angle (1,1) double = 0#

Rotation angle in degrees

CenterSize (1,4) double = [512.5,512.5,1024,1024]#

[centerY,centerX,sizeY,sizeX]

CornerList#

Corner coordinates of ROI

ImageSize (1,2) double#

Original image dimensions [height, width]

ImageSizeRotated (1,2) double#

Image size after rotation

IsSubRoi logical = false#

Whether this is a sub-ROI

NSub#

Number of sub-ROIs

Name string#

ROI name identifier

SubRoi Roi#

Array of sub-ROI objects

SubRoiCenterSize double#

Sub-ROI center and size specifications

SubRoiNRowColumn (1,2) double = [1,1]#

Number of sub-ROI rows and columns

SubRoiSeparation (1,2) double = [100,100]#

Separation between sub-ROIs

XList#

List of x-coordinates within ROI

YList#

List of y-coordinates within ROI

YXBoundary (1,4) double = [1,1024,1,1024]#

ROI boundaries [Y1,Y2,X1,X2]

Method Summary
createMask(maskPoints)#

Create a mask from polygon points.

Parameters:

maskPoints (double array) – Polygon points in full image coordinates

Returns:

Binary mask

Return type:

logical array

full2NoRotationFull(fullCoord)#

Convert rotated full coordinates to non-rotated full coordinates.

Parameters:

fullCoord (double array) – Rotated full coordinates

Returns:

Non-rotated full coordinates

Return type:

double array

full2Roi(fullCoord)#

Convert full image coordinates to ROI coordinates.

Parameters:

fullCoord (double array) – Full image coordinates

Returns:

ROI coordinates

Return type:

double array

grid(nRow, nColumn)#

Create a grid of sub-ROIs.

Parameters:
  • nRow (double) – Number of rows

  • nColumn (double) – Number of columns

isInRoi(fullCoord)#

Check if coordinates are within ROI boundaries.

Parameters:

fullCoord (double array) – Full image coordinates

Returns:

Whether coordinates are in ROI

Return type:

logical

isNoRotationFullInRoi(noRotFullCoord)#

Check if non-rotated coordinates are within ROI.

Parameters:

noRotFullCoord (double array) – Non-rotated full coordinates

Returns:

Whether coordinates are in ROI

Return type:

logical

static loadobj(s)#

Load ROI object from structure.

Parameters:

s (struct) – Structure containing ROI data

Returns:

ROI object

Return type:

Roi

noRotationFull2Full(noRotFullCoord)#

Convert non-rotated full coordinates to rotated full coordinates.

Parameters:

noRotFullCoord (double array) – Non-rotated full coordinates

Returns:

Rotated full coordinates

Return type:

double array

noRotationFull2Roi(noRotFullCoord)#

Convert non-rotated full coordinates to ROI coordinates.

Parameters:

noRotFullCoord (double array) – Non-rotated full coordinates

Returns:

ROI coordinates

Return type:

double array

roi2Full(roiCoord)#

Convert ROI coordinates to full image coordinates.

Parameters:

roiCoord (double array) – ROI coordinates

Returns:

Full image coordinates

Return type:

double array

roi2NoRotationFull(roiCoord)#

Convert ROI coordinates to non-rotated full coordinates.

Parameters:

roiCoord (double array) – ROI coordinates

Returns:

Non-rotated full coordinates

Return type:

double array

rotate(rotateAngle)#

Rotate ROI about its center.

Parameters:

rotateAngle (double) – Additional rotation angle in degrees

saveobj()#

Save ROI object to structure.

Returns:

Structure containing ROI data

Return type:

struct

select(mData)#

Extract ROI data from input image.

Parameters:

mData (double array) – Input image data

Returns:

ROI data

Return type:

double array

selectSub(mData)#

Extract data from all sub-ROIs.

Parameters:

mData (double array) – Input image data

Returns:

Cell array of sub-ROI data

Return type:

cell array

setSub()#

Create sub-ROI objects based on current settings.