Skip to content

Images should be scaled to the same pixel size #27

Description

@MicheleBortol

At the moment we are using a simple scale factor, but it would be better to scale the images to the same pixel size before registration. We can easily get both the Xenium and MACSima pixel sizes from their metadata and we can convert the scale_factor parameter to a desired pixel size for registration. The current approximate setup seems to work OK, but could be improved. See:

  • def preprocess_reg(img, scale_factor):
    """
    Prepares an image for use with cv SIFT feature detection.
    Parameters:
    -----------
    img : dask.array or numpy.ndarray
    Input image to preprocess
    scale_factor : int
    Downscaling factor for the image
    Returns:
    --------
    numpy.ndarray
    Preprocessed image ready for SIFT feature detection
    """
    matrix = np.array([[scale_factor, 0, 0], [0, scale_factor, 0], [0, 0, 1]])
    output_shape = np.asarray(img.shape)
    output_shape = (output_shape / scale_factor).astype("uint16")
    img = dask_image.ndinterp.affine_transform(
    img,
    matrix=matrix,
    output_shape=output_shape,
    )
    img = skimage.exposure.equalize_adapthist(img)
    img = (img - np.min(img)) / (np.max(img) - np.min(img)) * 255
    img = img.astype("uint8")
  • parser.add_argument("scale_factor", help="Scale Factor for downsampling")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions