constitch.merging
index
/home/nicho/starcall-docs/constitch/merging.py

 
Modules
       
numpy
skimage
sys
constitch.utils

 
Classes
       
builtins.object
Merger
EfficientMeanMerger
EfficientNearestMerger
LastMerger
MeanMerger
NearestMerger
MaskMerger

 
class EfficientMeanMerger(Merger)
    A version of MeanMerger that does not require double the memory, however there is a small loss of 
precision as calculation errors can add up as images are merged. It is recommended to start with
MeanMerger and if memory becomes an issue switch to this one.
 
 
Method resolution order:
EfficientMeanMerger
Merger
builtins.object

Methods defined here:
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.

Data descriptors inherited from Merger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class EfficientNearestMerger(Merger)
    This merger does the same as the NearestMerger but it does it with only an extra array of
uint8, halfing the extra memory requirements. The downside is that it will only trim up to 255
pixels away from the edge of images, so if the overlap between your images is much larger than
this, this merger will not give the same results.
 
 
Method resolution order:
EfficientNearestMerger
Merger
builtins.object

Methods defined here:
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.

Data descriptors inherited from Merger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class LastMerger(Merger)
    This is the simplest merger, overlap is decided just by which image was added last.
This also means it has no extra memory requirements, if your images have no overlap or
you don't need any merging this is the best choice.
 
 
Method resolution order:
LastMerger
Merger
builtins.object

Methods defined here:
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.

Data descriptors inherited from Merger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class MaskMerger(NearestMerger)
    MaskMerger(overlap_threshold=0.75, dtype=<class 'numpy.uint32'>)
 
This merger is specifically for merging an image mask, where each integer represents
an independent class, for example cell segmentation masks. Other merging techniques won't
work on these image masks. This merger first makes sure that every mask in each image
has a unique integer value, then merges overlapping sections by going through the
masks and combining masks that are mostly overlapping in both images. The amount
of overlap needed to combine masks is the overlap_threshold.
 
 
Method resolution order:
MaskMerger
NearestMerger
Merger
builtins.object

Methods defined here:
__init__(self, overlap_threshold=0.75, dtype=<class 'numpy.uint32'>)
Initialize self.  See help(type(self)) for accurate signature.
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.

Methods inherited from NearestMerger:
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.

Data descriptors inherited from Merger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class MeanMerger(Merger)
    A merger that calculates the mean of any overlapping areas. This requires
storing the whole image using a larger dtype, eg when merging uint16 images
the whole image will be stored as a uint32 image to account for possible overflow.
This will double the memory requirements compared to other mergers such as LastMerger
or EfficientMeanMerger.
 
 
Method resolution order:
MeanMerger
Merger
builtins.object

Methods defined here:
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.
promote_dtype(self, dtype)

Data descriptors inherited from Merger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Merger(builtins.object)
    Abstract class that specifies the methods required for an image merger.
At its heart an image merger is a method for handling multiple values at one
pixel location, either taking one, combining them all, or some other method.
Using this the merger is able to combine many images at different locations
into one final image.
The simplest merger is LastMerger, which doesn't do any extra processing, it
simply places each image on top of each other, meaning overlapping areas will
be the last image added. Other mergers attempt to combine images better but
this requires using more memory and processing.
 
  Methods defined here:
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class NearestMerger(Merger)
    This merger keeps the pixel that is closer to the center of its image when there is overlap.
This normally means that the edges of images are removed and central pixels are prioritized.
This does require more memory, an extra array of uint16 the size of the final image. If memory
is an issue EfficientNearestMerger uses a similar algorithm but only needs an array of uint8.
 
 
Method resolution order:
NearestMerger
Merger
builtins.object

Methods defined here:
add_image(self, image, location)
Called to add an image. location is a tuple of slices used
to select the area for the image, it is guaranteed to be the
same size as image.
create_image(self, image_shape, image_dtype)
Init is called with the shape of the final image (may be
more than 2d) and the dtype. Normally a merger would create
an image using this information.
final_image(self)
Called once to get the final image. It will only be called
once when stitching, so final processing can take place and modify
the stored image. Returns the final image and a mask for pixels that
had no images.

Data descriptors inherited from Merger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)