fissa.ROI module¶
The functions below were adapted from the sima package http://www.losonczylab.org/sima version 1.3.0.
License¶
This file is Copyright (C) 2014 The Trustees of Columbia University in the City of New York.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
-
fissa.ROI.
poly2mask
(polygons, im_size)[source]¶ Converts polygons to a sparse binary mask.
>>> from fissa.ROI import poly2mask >>> poly1 = [[0,0], [0,1], [1,1], [1,0]] >>> poly2 = [[0,1], [0,2], [2,2], [2,1]] >>> mask = poly2mask([poly1, poly2], (3, 3)) >>> mask[0].todense() matrix([[ True, False, False], [ True, True, False], [False, False, False]], dtype=bool)
Parameters: - polygons (sequence of coordinates or sequence of Polygons) – A sequence of polygons where each is either a sequence of (x,y) or (x,y,z) coordinate pairs, an Nx2 or Nx3 numpy array, or a Polygon object.
- im_size (tuple) – Final size of the resulting mask
Returns: masks – A list of sparse binary masks of the points contained within the polygons, one mask per plane. Each mask is in linked list sparse matrix format.
Return type: list of sparse matrices