imaging
#
Image processing and analysis
Automatic search of the spinning disk's circle |
|
Segmentation of cells in thresholded image |
|
Curve fit of cell density versus shear stress |
- write(target: Path, image: ndarray | Image, overwrite=False)[source]#
Saves the
image
as the giventarget
file.An appropriate compression method is selected depending on the image format of the file, which is inferred from the file’s suffix, e.g.
.tif
or.jpg
. Lossless compression is used for formats that support it, such as.tif
and.png
. The level of compression we select strikes a balance between small file size and fast output speed.
- compress(source: Path, target: Path, grayscale=False)[source]#
Compresses the
source
image file and saves it astarget
.The file format of the target is inferred from the file suffix, for example
.tif
for the TIFF image format. Optionally, the image can be converted tograyscale
, which means averaging over the color channels.
- sort_into_grid(folder: Path, suffix='.png') ndarray[Path] [source]#
Finds input images in
folder
and sorts them into the correct grid.The control software of the spinning-disk microscope outputs partial images acquired while scanning the full area. We need to find those images among other files possibly residing in the same folder and arrange them correctly. The position of an individual image in the scan grid is encoded in its file name.
Note that, in the past, there have been bugs in the acquisition software that resulted in incorrectly names files.
Raises appropriate exceptions if, for whatever reason, the folder does not contain the expected set of input images.
Returns a 2d array of
files
.
- stitch(files: ndarray[Path], target: Path)[source]#
Stitches scan-grid images into the full image.
The
files
must be passed in as a 2d array, the shape of which determines the grid. That is typically the result returned bysort_into_grid()
. The stitched image will be saved astarget
.
- tile(source: Path, target: Path, tile_size: int = 512, overlap: int = 0)[source]#
Creates a tiled zoom-level pyramid from a large image.
The
source
file is typically a high-resolution image that is intended to be displayed interactively, at various zoom levels. Thetarget
must be a.dzi
file. The input image will be converted to the DeepZoom format, essentially a collection of small tiles (which may or may not overlap somewhat). Internally, the individual tiles are just.png
images that can be quickly loaded from disk for given zoom level and position in the larger image.
- rolling_ball(image: ndarray, radius: int = 50) ndarray [source]#
Removes the background from the
image
using the rolling-ball method.Returns the image foreground obtained by subtracting the background from the input image.
- thresholding_bernsen(image: ndarray, radius: int = 15, contrast: int = 15) ndarray [source]#
Returns the local segmentation thresholds using the Bernsen method.
The parameters window
radius
andcontrast
threshold correspond to the ImageJ definitions, though the Python implementation actually uses a square window with a side length corresponding to the diameter.