Visualization

Various functions used to visualize registration results

valis.viz.cam16ucs_cmap(luminosity=0.8, colorfulness=0.5, max_h=300)[source]

Get colormap based on CAM16-UCS colorspace.

Parameters
  • luminosity (float, optional) –

  • colorfulness (float, optional) –

  • max_h (int, optional) –

valis.viz.color_displacement_grid(bk_dx, bk_dy, c_range=(0, 0.025), l_range=(0.004, 0.015), thickness=None, grid_spacing_ratio=0.02, cspace='JzAzBz')[source]

Color a displacement grid

valis.viz.color_displacement_tri_grid(bk_dx, bk_dy, img=None, n_grid_pts=25, c_range=(0, 0.025), l_range=(0.004, 0.015), thickness=None, cspace='JzAzBz')[source]

View how a displacement warps a triangular mesh.

valis.viz.color_dxdy(dx, dy, c_range=(0, 0.025), l_range=(0.004, 0.015), cspace='JzAzBz')[source]

Color displacement, where larger displacements are more colorful, and, if scale_l=True, brighter.

dx: array

1D Array containing the displacement in the X (column) direction

dy: array

1D Array containing the displacement in the Y (row) direction

c_range: (float, float)

Minimum and maximum colorfulness in JzAzBz colorspace

l_range: (float, float)

Minimum and maximum luminosity in JzAzBz colorspace

scale_l: boolean

Scale the luminosity based on magnitude of displacement

displacement_rgbarray

RGB (0, 255) color for each displacement, with the same shape as dx and dy

valis.viz.color_multichannel(multichannel_img, marker_colors, rescale_channels=False, normalize_by='image', cspace='Hunter Lab')[source]

Color a multichannel image to view as RGB

Parameters
  • multichannel_img (ndarray) – Image to color

  • marker_colors (ndarray) – sRGB colors for each channel.

  • rescale_channels (bool) – If True, then each channel will be scaled between 0 and 1 before building the composite RGB image. This will allow markers to ‘pop’ in areas where they are expressed in isolation, but can also make it appear more marker is expressed than there really is.

  • normalize_by (str, optionaal) –

    “image” will produce an image where all values are scaled between 0 and the highest intensity in the composite image. This will produce an image where one can see the expression of each marker relative to the others, making it easier to compare marker expression levels.

    ”channel” will first scale the intensity of each channel, and then blend all of the channels together. This will allow one to see the relative expression of each marker, but won’t allow one to directly compare the expression of markers across channels.

  • cspace (str) – Colorspace in which marker_colors will be blended. JzAzBz, Hunter Lab, and sRGB all work well. But, see colour.COLOURSPACE_MODELS for other possible colorspaces

Returns

rgb – An sRGB version of multichannel_img

Return type

ndarray

valis.viz.draw_features(kp_xy, image, n_features=500)[source]

Draw keypoints on a image

valis.viz.draw_matches(src_img, kp1_xy, dst_img, kp2_xy, rad=3, alignment='horizontal')[source]

Draw feature matches between two images

Parameters
  • src_img (ndarray) – Image associated with kp1_xy

  • kp1_xy (ndarray) – xy coordinates of feature points found in src_img

  • dst_img (ndarray) – Image associated with kp2_xy

  • kp2_xy (ndarray) – xy coordinates of feature points found in dst_img

  • rad (int) – Radius of circles used to draw feature points

  • alignment (string) – How to stack the images, either ‘veritcal’ or ‘horizontal’.

Returns

feature_img – Image show corresponding features of src_img and dst_img

Return type

ndarray

valis.viz.get_n_colors(rgb, n)[source]

Pick n most different colors in rgb. Differences based of rgb values in the CAM16UCS colorspace Based on https://larssonjohan.com/post/2016-10-30-farthest-points/

valis.viz.jzazbz_cmap(luminosity=0.012, colorfulness=0.02, max_h=260)[source]

Get colormap based on JzAzBz colorspace, which has good hue linearity. Already preceptually uniform.

Parameters
  • luminosity (float, optional) –

  • colorfulness (float, optional) –

  • max_h (int, optional) –

valis.viz.turbo_cmap()[source]

Turbo colormap https://gist.github.com/mikhailov-work/ee72ba4191942acecc03fe6da94fc73f