Welcome to pythologist-image-utilities’s documentation!¶
Readme File¶
pythologist-image-utilities¶
For function details please Read The Docs
Functions for working with image data in python
About¶
This set of functions are used in the construction of pythologist-reader intermediate storage format, and in the analysis of image data .. finding neighbors .. or the generation of images.
Modules¶
-
pythologist_image_utilities.
binary_image_dilation
(np_array, steps=1)[source]¶ For an input image that gets set to 0 or 1, expand the 1’s by the number of steps
- Parameters
np_array (numpy.array) – a 2d image
steps (int) – number of pixels to expand
- Returns
Image with that has been expanded
- Return type
numpy.array
-
pythologist_image_utilities.
flood_fill
(image, x, y, exit_criteria, max_depth=1000, recursion=0, visited=None, border_trim=1)[source]¶ There is a flood_fill in scikit-image 0.15.dev0, but it is not faster than this for this application. It may be good to revisit skikit’s implemention if it is optimized.
- Parameters
image (numpy.array) – a 2d numpy array image
x (int) – x starting coordinate
y (int) – y starting coordinate
exit_criteria (function) – a function for which to exit i.e.
lambda x: x!=0
max_depth (int) – a maximum recurssion depth
recursion (int) – not set by user, used to keep track of recursion depth
visited (list) – list of (x,y) tuple representing coordinates that have been visited
border_trim (int) – the size of the border to avoid on the edge
- Returns
the filled image
- Return type
numpy.array
-
pythologist_image_utilities.
image_edges
(image, verbose=False)[source]¶ Take an image of cells where pixel intensitiy integer values represent cell ids (fully filled-in) and return just the edges
- Parameters
image (numpy.array) – A 2d numpy array of integers coding for cell IDs
verbose (bool) – If true output more details to stderr
- Returns
an output image of just edges
- Return type
numpy.array
-
pythologist_image_utilities.
make_binary_image_array
(np_array)[source]¶ Make a binary (one channel) image from a drawn color image
- Parameters
np_array (numpy.array) –
- Returns
an array that is 1 where something (anything) existed vs 0 where there was nothing
- Return type
numpy.array
-
pythologist_image_utilities.
map_image_ids
(image, remove_zero=True)[source]¶ Convert an image into a list of coordinates and the id (coded by pixel integer value)
- Parameters
image (numpy.array) – A numpy 2d array with the integer values representing cell IDs
remove_zero (bool) – If True (default), remove all zero pixels
- Returns
A pandas dataframe with columns shaped as <x><y><id>
- Return type
pandas.DataFrame
-
pythologist_image_utilities.
median_id_coordinates
(np_array, exclude_points=None)[source]¶ Locate a coordinate near the center of each object in an image
- Parameters
np_array (numpy.array) – Take an image where pixels code for the IDs
exclude_points (list) – optional. a list of tuples of ‘x’,’y’ coordinates. to exclude from being possible median outputs
- Returns
DataFrame indexed by ID with a near median ‘x’, and median ‘y’ for that ID
- Return type
pandas.DataFrame
-
pythologist_image_utilities.
read_tiff_stack
(filename)[source]¶ Read in a tiff filestack into individual images and their metadata
-
pythologist_image_utilities.
watershed_image
(np_array, starting_points, valid_target_points, steps=1, border=1)[source]¶ A function for expanding a set of pixels in an image from starting_points and into valid_target_points.
- Parameters
np_array (numpy.array) – A 2d array of the image where comprised of integer values
starting_points (list) – a list of (x,y) tuples to begin filling out from. the values of these points
valid_target_points (list) – a list of (x,y) tuples of valid locations to expand into
steps (int) – the number of times to execute the watershed
border (int) – the distance to remain away from the edge of the image
- Returns
the image with the watershed executed
- Return type
numpy.array