Image Registration (nornir_imageregistration)¶
alignment_record¶

class
nornir_imageregistration.alignment_record.
AlignmentRecord
(peak, weight, angle=0.0)¶ Records basic registration information as an angle and offset between a fixed and moving image If the offset is zero the center of both images occupy the same point. The offset determines the translation of the moving image over the fixed image. There is no support for scale, and there should not be unless added as another variable to the alignment record
Parameters:
core¶
scipy image arrays are indexed [y,x]

nornir_imageregistration.core.
ConstrainedRange
(start, count, maxVal, minVal=0)¶ Returns a range that falls within min/max limits.

nornir_imageregistration.core.
CreateOverlapMask
(FixedImageSize, MovingImageSize, MinOverlap=0.0, MaxOverlap=1.0)¶ Defines a mask that determines which peaks should be considered

nornir_imageregistration.core.
CropImage
(imageparam, Xo, Yo, Width, Height, cval=None)¶ Crop the image at the passed bounds and returns the cropped ndarray. If the requested area is outside the bounds of the array then the correct region is returned with a background color set
Parameters:  imageparam (ndarray) – An ndarray image to crop. A string containing a path to an image is also acceptable.e
 Xo (int) – X origin for crop
 Yo (int) – Y origin for crop
 Width (int) – New width of image
 Height (int) – New height of image
 cval (int) – default value for regions outside the original image boundaries. Defaults to 0. Use ‘random’ to fill with random noise matching images statistical profile
Returns: Cropped image
Return type: ndarray

nornir_imageregistration.core.
CropNonOverlapping
(FixedImageSize, MovingImageSize, CorrelationImage, MinOverlap=0.0, MaxOverlap=1.0)¶

nornir_imageregistration.core.
DimensionWithOverlap
(val, overlap=1.0)¶ Parameters: Returns: Required dimension size to unambiguously determine the offset in an fft image

nornir_imageregistration.core.
ExtractROI
(image, center, area)¶ Returns an ROI around a center point with the area, if the area passes a boundary the ROI maintains the same area, but is shifted so the entire area remains in the image. USES NUMPY (Y,X) INDEXING

nornir_imageregistration.core.
FFTPhaseCorrelation
(FFTFixed, FFTMoving, delete_input=False)¶ Returns the phase shift correlation of the FFT’s of two images.
Dimensions of Fixed and Moving images must match
Parameters:  FixedImage (ndarray) – grayscale image
 MovingImage (ndarray) – grayscale image
Returns: Correlation image of the FFT’s. Light pixels indicate the phase is well aligned at that offset.
Return type: ndimage

nornir_imageregistration.core.
FindOffset
(FixedImage, MovingImage, MinOverlap=0.0, MaxOverlap=1.0, FFT_Required=True)¶ return an alignment record describing how the images overlap. The alignment record indicates how much the moving image must be rotated and translated to align perfectly with the FixedImage

nornir_imageregistration.core.
FindPeak
(image, Cutoff=0.995, MinOverlap=0, MaxOverlap=1)¶ Find the offset of the strongest response in a phase correlation image
Parameters: Returns: Offset of peak from image center and sum of pixels values at peak
Return type: (tuple, float)

nornir_imageregistration.core.
ForceGrayscale
(image)¶ Param: ndarray with 3 dimensions Returns: grayscale data Return type: ndarray with 2 dimensions

nornir_imageregistration.core.
GenRandomData
(height, width, mean, standardDev)¶ Generate random data of shape with the specified mean and standard deviation

nornir_imageregistration.core.
GetImageSize
(ImageFullPath)¶ Returns: Image (height, width) Return type: tuple

nornir_imageregistration.core.
ImageIntensityAtPercent
(image, Percent=0.995)¶ Returns the intensity of the Cutoff% most intense pixel in the image

nornir_imageregistration.core.
ImagePhaseCorrelation
(FixedImage, MovingImage)¶ Returns the phase shift correlation of the FFT’s of two images.
Dimensions of Fixed and Moving images must match
Parameters:  FixedImage (ndarray) – grayscale image
 MovingImage (ndarray) – grayscale image
Returns: Correlation image of the FFT’s. Light pixels indicate the phase is well aligned at that offset.
Return type: ndimage

class
nornir_imageregistration.core.
ImageStats
¶ A container for image statistics

nornir_imageregistration.core.
ImageToTiles
(source_image, tile_size, grid_shape=None, cval=0)¶ Parameters:  source_image (ndarray) – Image to cut into tiles
 tile_size (array) – Shape of each tile
 grid_shape (array) – Dimensions of grid, if None the grid is large enough to reproduce the source_image with zero padding if needed
 cval (object) – Fill value for images that are padded. Default is zero. Use ‘random’ to generate random noise
Returns: Dictionary of images indexed by tuples

nornir_imageregistration.core.
ImageToTilesGenerator
(source_image, tile_size, grid_shape=None, cval=0)¶ An iterator generating all tiles for an image :param array tile_size: Shape of each tile :param array grid_shape: Dimensions of grid, if None the grid is large enough to reproduce the source_image with zero padding if needed :param object cval: Fill value for images that are padded. Default is zero. Use ‘random’ to generate random noise :return: (iCol,iRow, tile_image)

nornir_imageregistration.core.
LoadImage
(ImageFullPath, ImageMaskFullPath=None, MaxDimension=None)¶ Loads an image converts to greyscale, masks it, and removes extrema pixels.
Parameters: Returns: Loaded image. Masked areas and extrema pixel values are replaced with gaussian noise matching the median and std. dev. of the unmasked image.
Return type: ndimage

nornir_imageregistration.core.
NearestPowerOfTwoWithOverlap
(val, overlap=1.0)¶ Returns: Same as DimensionWithOverlap, but output dimension is increased to the next power of two for faster FFT operations

nornir_imageregistration.core.
NormalizeImage
(image)¶ Adjusts the image to have a range of 0 to 1.0

nornir_imageregistration.core.
PadImageForPhaseCorrelation
(image, MinOverlap=0.05, ImageMedian=None, ImageStdDev=None, NewWidth=None, NewHeight=None, PowerOfTwo=True)¶ Prepares an image for use with the phase correlation operation. Padded areas are filled with noise matching the histogram of the original image. Optionally the min/max pixels can also replaced be replaced with noise using FillExtremaWithNoise
Parameters:  image (ndarray) – Input image
 MinOverlap (float) – Minimum overlap allowed between the input image and images it will be registered to
 ImageMean (float) – Median value of noise, calculated or pulled from cache if none
 ImageStdDev (float) – Standard deviation of noise, calculated or pulled from cache if none
 NewWidth (int) – Pad input image to this dimension if not none
 NewHeight (int) – Pad input image to this dimension if not none
 PowerOfTwo (bool) – Pad the image to a power of two if true
Returns: An image with the input image centered surrounded by noise
Return type: ndimage

nornir_imageregistration.core.
ROIRange
(start, count, maxVal, minVal=0)¶ Returns a range that falls within the limits, but contains count entries.

nornir_imageregistration.core.
RandomNoiseMask
(image, Mask, ImageMedian=None, ImageStdDev=None, Copy=False)¶ Fill the masked area with random noise with gaussian distribution about the image mean and with standard deviation matching the image’s standard deviation
Parameters:  image (ndimage) – Input image
 mask (ndimage) – Mask, zeros are replaced with noise. Ones pull values from input image
 ImageMedian (float) – Mean of noise distribution, calculated from image if none
 ImageStdDev (float) – Standard deviation of noise distribution, calculated from image if none
 Copy (bool) – Returns a copy of input image if true, otherwise write noise to the input image
Return type: ndimage

nornir_imageregistration.core.
ReplaceImageExtramaWithNoise
(image, ImageMedian=None, ImageStdDev=None)¶ Replaced the min/max values in the image with random noise. This is useful when aligning images composed mostly of dark or bright regions

nornir_imageregistration.core.
ResizeImage
(image, scalar)¶ Change image size by scalar

nornir_imageregistration.core.
SaveImage
(ImageFullPath, image, **kwargs)¶ Saves the image as greyscale with no contraststretching

nornir_imageregistration.core.
SaveImage_JPeg2000
(ImageFullPath, image, tile_dim=None)¶ Saves the image as greyscale with no contraststretching

nornir_imageregistration.core.
ScalarForMaxDimension
(max_dim, shapes)¶ Returns the scalar value to use so the largest dimensions in a list of shapes has the maximum value

nornir_imageregistration.core.
ShowGrayscale
(imageList, title=None)¶ Parameters:  imageList (list) – A list or single ndimage to be displayed with imshow
 title (str) – Informative title for the figure, for example expected test results

nornir_imageregistration.core.
TileGridShape
(source_image_shape, tile_size)¶ Given an image and tile size, return the dimensions of the grid

nornir_imageregistration.core.
array_distance
(array)¶ Convert an Mx2 array into a Mx1 array of euclidean distances

class
nornir_imageregistration.core.
memmap_metadata
(path, shape, dtype, mode=None)¶ metadata for a memmap array
Returns a shared memory array for a numpy array. Used to reduce memory footprint when passing parameters to multiprocess pools
assemble¶
Created on Apr 22, 2013

nornir_imageregistration.assemble.
DestinationROI_to_SourceROI
(transform, botleft, area, extrapolate=False)¶ Apply a transform to a region of interest within an image. Center and area are in fixed space
Parameters:  transform (transform) – The transform used to map points between fixed and mapped space
 botleft (1x2_array) – The (Y,X) coordinates of the bottom left corner
 area (1x2_array) – The (Height, Width) of the region of interest
 exrapolate (bool) – If true map points that fall outside the bounding box of the transform
Returns: Tuple of arrays. First array is fixed space coordinates. Second array is warped space coordinates.
Return type: tuple(Nx2 array,Nx2 array)

nornir_imageregistration.assemble.
ExtractRegion
(image, botleft=None, area=None, cval=0)¶ Extract a region from an image
Parameters:  image (ndarray) – Source image
 botleft (1x2_array) – The (Y,X) coordinates of the bottom left corner
 area (1x2_array) – The (Height, Width) of the region of interest
Returns: Image of requested region
Return type: ndarray

nornir_imageregistration.assemble.
FixedImageToWarpedSpace
(transform, WarpedImageArea, DataToTransform, botleft=None, area=None, cval=None, extrapolate=False)¶ Warps every image in the DataToTransform list using the provided transform. :Param transform: transform to pass warped space coordinates through to obtain fixed space coordinates :Param FixedImageArea: Size of fixed space region to map pixels into :Param DataToTransform: Images to read pixel values from while creating fixed space images. A list of images can be passed to map multiple images using the same coordinates. A list may contain filename strings or numpy.ndarrays :Param botleft: Origin of region to map :Param area: Expected dimensions of output :Param cval: Value to place in unmappable regions, defaults to zero. :param bool exrapolate: If true map points that fall outside the bounding box of the transform

nornir_imageregistration.assemble.
ParameterToStosTransform
(transformData)¶ Parameters: transformData (object) – Either a full path to a .stos file, a stosfile, or a transform object Returns: A transform

nornir_imageregistration.assemble.
SourceROI_to_DestinationROI
(transform, botleft, area, extrapolate=False)¶ Apply an inverse transform to a region of interest within an image. Center and area are in fixed space
Parameters:  transform (transform) – The transform used to map points between fixed and mapped space
 botleft (1x2_array) – The (Y,X) coordinates of the bottom left corner
 area (1x2_array) – The (Height, Width) of the region of interest
 exrapolate (bool) – If true map points that fall outside the bounding box of the transform
Returns: Tuple of arrays. First array is fixed space coordinates. Second array is warped space coordinates.
Return type: tuple(Nx2 array,Nx2 array)

nornir_imageregistration.assemble.
TransformImage
(transform, fixedImageShape, warpedImage)¶ Cut image into tiles, assemble small chunks

nornir_imageregistration.assemble.
TransformStos
(transformData, OutputFilename=None, fixedImageFilename=None, warpedImageFilename=None, scalar=1.0, CropUndefined=False)¶ Assembles an image based on the passed transform. :param bool fixedImageFilename: Image describing the size we want the warped image to fill :param bool warpedImageFilename: Image we will warp into fixed space :param float scalar: Amount to scale the transform before passing the image through :param bool CropUndefined: If true do exclude areas outside the convex hull of the transform, if it exists :param bool Dicreet: True causes points outside the defined transform region to be clipped instead of interpolated :return: transformed image

nornir_imageregistration.assemble.
WarpedImageToFixedSpace
(transform, FixedImageArea, DataToTransform, botleft=None, area=None, cval=None, extrapolate=False)¶ Warps every image in the DataToTransform list using the provided transform. :Param transform: transform to pass warped space coordinates through to obtain fixed space coordinates :Param FixedImageArea: Size of fixed space region to map pixels into :Param DataToTransform: Images to read pixel values from while creating fixed space images. A list of images can be passed to map multiple images using the same coordinates. A list may contain filename strings or numpy.ndarrays :Param botleft: Origin of region to map :Param area: Expected dimensions of output :Param cval: Value to place in unmappable regions, defaults to zero. :param bool exrapolate: If true map points that fall outside the bounding box of the transform
assemble_tiles¶
Created on Oct 28, 2013
Deals with assembling images composed of mosaics or dividing images into tiles