roi

Region of interest creation

class pdsspect.roi.ROIBase(image_set, view_canvas, color='red', linewidth=1, linestyle='solid', showcap=False, fill=True, fillcolor=None, alpha=1.0, drawdims=False, font='Sans Serif', fillalpha=1.0, **kwargs)[source]

Bases: ginga.canvas.types.basic.Polygon

Base class for all ROI shapes

contains_arr(x_arr, y_arr)[source]

Determine whether the points in the ROI are in arrays

The arrays must be the same shape. The arrays should be result of np.mgrid[y1:y2:1, x1:x2:1]

Parameters:
Returns:

result – Boolean array where coordinates that are in ROI are True

Return type:

numpy.ndarray

continue_ROI(data_x, data_y)[source]

Abstract method to continue the ROI process

create_ROI(points=None)[source]

Create a Region of interest

Parameters:points (list of tuple of two int) – Points that make up the vertices of the ROI
Returns:coordinatesm x 2 array of coordinates.
Return type:numpy.ndarray
static draw_after(func)[source]

Wrapper to redraw canvas after function

extend_ROI(data_x, data_y)[source]

Abstract method to extend the ROI process

lock_coords_to_pixel(data_x, data_y)[source]

Lock the coordinates to the pixel

The coordinate of the pixel is located at the bottom left corner of the pixel square while the center of the pixel .5 units up and to the right of the corner. So if the given coordinates are (2.3, 3.7), the pixel coordinates will be (2, 3) and the center of the pixel is (2.5, 3.5). This method locks the given coordinates to the pixel’s coordinates

Parameters:
  • data_x (float) – The given x coordinate
  • data_y (float) – The given y coordinate
Returns:

  • point_x (float) – The corresponding x pixel coordinate
  • point_y (float) – The corresponding y pixel coordinate

static lock_coords_to_pixel_wrapper(func)[source]

Wrapper to lock data coordinates to the corresponding pixels

start_ROI(data_x, data_y)[source]

Abstract method to start the ROI process

stop_ROI(data_x, data_y)[source]

Abstract method to stop the ROI process

class pdsspect.roi.Polygon(image_set, view_canvas, color='red', linewidth=1, linestyle='solid', showcap=False, fill=True, fillcolor=None, alpha=1.0, drawdims=False, font='Sans Serif', fillalpha=1.0, **kwargs)[source]

Bases: pdsspect.roi.ROIBase

Polygon Region of Interest

continue_ROI(data_x, data_y)[source]

Create new vertex on the polygon on left click

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
extend_ROI(data_x, data_y)[source]

Extend the current edge of the polygon on mouse motion

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
start_ROI(data_x, data_y)[source]

Start the ROI process

The ROI will be a ginga.canvas.types.basic.Path object

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
stop_ROI(data_x, data_y)[source]

Close the polygon on right click

The polygon will close based on last left click and not on the right click. There must be more than 2 points to formulate a polygon

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
class pdsspect.roi.Rectangle(image_set, view_canvas, color='red', linewidth=1, linestyle='solid', showcap=False, fill=True, fillcolor=None, alpha=1.0, drawdims=False, font='Sans Serif', fillalpha=1.0, **kwargs)[source]

Bases: pdsspect.roi.ROIBase

Rectangle Region of interest

extend_ROI(data_x, data_y)[source]

Exend the rectangle on region of interest on mouse motion

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
start_ROI(data_x, data_y)[source]

Start the region of interest on left click

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
stop_ROI(data_x, data_y)[source]

Stop the region of interest on right click

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
class pdsspect.roi.Pencil(*args, **kwargs)[source]

Bases: pdsspect.roi.ROIBase

Select individual pixels

continue_ROI(data_x, data_y)[source]

Add another pixel on left click

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
move_delta(delta_x, delta_y)[source]

Override the move_delta function to move all the points

Parameters:
  • delta_x (float) – Change in the x direction
  • delta_y (float) – Change in the y direction
start_ROI(data_x, data_y)[source]

Start choosing pixels on left click

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
stop_ROI(data_x, data_y)[source]

Set all pixels as roi cooridinates on right click

Parameters:
  • data_x (float) – The x coordinate
  • data_y (float) – The y coordinate
Returns:

coordinates – Coordinates of points selected

Return type:

numpy.ndarray