2.1.2.1.5. sf_tools.image.stamp module¶
IMAGE STAMP SELECTION ROUTINES
This module contains methods for selecting stamps or patches from images.
Author: | Samuel Farrens <samuel.farrens@gmail.com> |
---|---|
Version: | 1.0 |
Date: | 20/10/2017 |
-
sf_tools.image.stamp.
patch_centres
(data_shape, layout)[source]¶ Image centres
This method inds the centres of the patches in a 2D map.
Parameters: Returns: Return type: np.ndarray array of patch centres
-
sf_tools.image.stamp.
postage_stamp
(data, pos, pixel_rad)[source]¶ Postage stamp
This metho selects a postage stamp of a given size from a 2D-array.
Parameters: Returns: Return type: np.ndarray rearanged matrix of kernel elements
Notes
The image edges are padded with zeros.
-
sf_tools.image.stamp.
pixel_pos
(array_shape)[source]¶ Pixel positions
This method returns all of the pixel positions from a 2D-array.
Parameters: array_shape (tuple) – Shape of array Returns: Return type: list of pixel positions
-
class
sf_tools.image.stamp.
FetchStamps
(data, pixel_rad, all=False)[source]¶ Bases:
object
Fetch postage stamps
This class returns a stack of postage stamps from a given 2D image array.
Parameters: - data (np.ndarray) – Input 2D data array
- pixel_rad (tuple) – Pixel radius in each dimension
- all (boolean, optional) – Option to select all pixels. Default (all=False)
-
_check_inputs
()[source]¶ Check inputs
This method checks the class variable values.
Raises: ValueError
– For invalid array dimensions or pixel radius values
-
_adjust_pixels
()[source]¶ Adjust pixels
This method adjusts the pixel positions according to the pixel radius.
-
get_pixels
(pixels)[source]¶ Get pixels
This method gets the desired pixel positions.
Parameters: pixels (list or np.ndarray) – List of pixel positions Raises: ValueError
– For invalid number of dimensions for pixel position array
-
n_pixels
(n_pixels=None, random=False)[source]¶ Number of pixels
This method selects a specified number of pixel positions.
Parameters:
-
_stamp
(pos, func=None, *args)[source]¶ Stamp
This method retrieves a postage stamp from the padded input data at a given position.
Parameters: - pos (tuple) – Pixel position in 2D padded array.
- func (function, optional) – Optional function to be applied to postage stamp.
Returns: Return type: np.ndarray postage stamp array or result of func
Raises: ValueError
– For for invalid size of pixel position.
-
scan
(func=None, *args, **kwargs)[source]¶ Scan stamps
This method scans the 2D padded input array and retrieves the postage stamps at all the desired pixel positions.
Parameters: func (function, optional) – Optional function to be applied to postage stamps. Returns: Return type: np.ndarray postage stamp arrays or results of func