pairwisehelper¶
Helper functions for the class pairwise alignment Creates its own logger object when imported.
Functions:
-
pysmFISH.stitching_package.pairwisehelper.
calc_translated_pics
(trans, overlap1, overlap2, round_size=False)[source]¶ Calculate wich part of 2 pictures overlap after translation.
Translates overlap2 and returns the parts of overlap1 and overlap2 that overlap after translation. Parts that do not overlap are cropped. The alternative would be to fill the parts that do not overlap with zeros, but this seems to mess up the covariance calculation more than cropping the pictures. Here, one problem is that we may crop unnecessarily much because the cropping is done on the overlap and not on the whole tile.
- trans: np.array
- 1 by 2 np-array with y and x translation.
- overlap1: np.array
- Image
- overlap2: np.array
- Image that is supposed to overlap with overlap1
- round_size: bool
- If True the final image sizes will be rounded to the nearest integer before warping the images. (Default: False)
- shifted_a: np.array
- Overlap a shifted and cropped to the same size as shifted_b
- shifted_b: np.array
- Overlap b shifted and cropped to the same size as shifted_a
-
pysmFISH.stitching_package.pairwisehelper.
calc_translated_pics_3D
(trans, overlap1, overlap2, round_size=False)[source]¶ Calculate wich part of two 3D pictures overlap after translation.
Translates overlap2 and returns the parts of overlap1 and overlap2 that overlap after translation. This function works in 3D but does not translate in z. Parts that do not overlap are cropped. The alternative would be to fill the parts that do not overlap with zeros, but this seems to mess up the covariance calculation more than cropping the pictures. Here, one problem is that we may crop unnecessarily much because the cropping is done on the overlap and not on the whole tile.
- trans: np.array
- 1 by 2 np-array with y and x translation.
- overlap1: np.array
- Image
- overlap2: np.array
- Image that is supposed to overlap with overlap1
- round_size: bool
- If True the final image sizes will be rounded to the nearest integer before warping the images. (Default: False)
- shifted_a: np.array
- Overlap a shifted and cropped to the same size as shifted_b
- shifted_b: np.array
- Overlap b shifted and cropped to the same size as shifted_a
-
pysmFISH.stitching_package.pairwisehelper.
calculate_PCM
(pic_a, pic_b)[source]¶ Calculate the phase correlation matrix of pic_a and pic_b.
- pic_a: np.array
- First picture
- pic_b: np.array
- Second picture
- r: np.array
- Normalized PCM matrix
pic_a and pic_b should have the same size
-
pysmFISH.stitching_package.pairwisehelper.
calculate_PCM_method2
(pic_a, pic_b)[source]¶ Calculate the phase correlation matrix of pic_a and pic_b.
Method 2 differs from calculate_PCM in that it calculates the PCM per, layer in the image therefore this function is only applicable to 3D images/complete z-stacks. In fact it is only used when in pairwisesingle.py if method == ‘calculate per layer’.
- pic_a: np.array
- First picture
- pic_b: np.array
- Second picture
- r: np.array
- Normalized PCM matrix
pic_a and pic_b should have the same size
-
pysmFISH.stitching_package.pairwisehelper.
display_overlap
(overlap1, overlap2, best_trans, best_cov, plot_order)[source]¶ Plot two pictures and show how they overlap.
This function will only plot when allow_plot is True and in inout matplotlib is imported and plot_available is True.
- overlap1: np.array
- 2d np-array representing an image
- overlap2: np.array
- 2d np-array representing an image
- best_trans: np.array
- 1 by 2 np array with an y and x value for the best transition
- best_cov: float
- Number indicating the goodness of the overlap between the two pictures
- plot_order: list
- The order in wich subplots should be placed if when plotting overlap1 and 2 and overlap rgb
-
pysmFISH.stitching_package.pairwisehelper.
get_overlapping_region
(tile_1, tile_2, overlap_ind_x, overlap_ind_y, direction)[source]¶ Given the overlap indexes calculate the overlap in direction.
- tile_1: np.array
- 2D or 3D numpy array representing an image.
- tile_2: np.array
- 2D or 3D numpy array representing an image.
- overlap_ind_x: int
- The difference in pixels between the tile corners in the x/column direction.
- overlap_ind_y: int
- The difference in pixels between the tile corners in the y/row direction.
- direction: str
- Valid values: ‘left’ or ‘top’. Denotes if the two tiles neighbour on the right and left or at the bottom and top.
- overlap_1: np.array
- 2D or 3D numpy arrays. The parts of each image that overlap.
- overlap_2: np.array
- 2D or 3D numpy arrays. The parts of each image that overlap.
-
pysmFISH.stitching_package.pairwisehelper.
xcov_nd
(pic_1, pic_2)[source]¶ Calculate the normalized cross covariance of pic_1 and pic_2.
- pic_1: np.array
- Numpy array representing a gray value picture, same size as pic_2
- pic_2: np.array
- Numpy array representing a gray value picture, same size as pic_1
- : float
- The normalized crosscovariance of pic_1 and pic_2 (coVar / (stDev1 * stDev2))
- monocolor: bool
- True if the one or both of the pictures contained only one color.