Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation when resampling images #166

Open
LucaMarconato opened this issue Mar 1, 2023 · 1 comment
Open

Interpolation when resampling images #166

LucaMarconato opened this issue Mar 1, 2023 · 1 comment

Comments

@LucaMarconato
Copy link
Member

LucaMarconato commented Mar 1, 2023

When applying a transformation to an image element or a labels element, or when rasterizing an image or labels, dask_image.ndinterp.affine_transform() is called (you can search this function to find the two occurrences in the code).

At the moment we use the following or equivalent code:

    if schema == Labels2DModel or schema == Labels3DModel:
        kwargs = {"prefilter": False, "order": 0}
    elif schema == Image2DModel or schema == Image3DModel:
        kwargs = {}
    else:
        raise ValueError(f"Unsupported schema {schema}")

to ensure that no interpolation is performed for labels, the result can be seen for instance here #165.

For images interpolation happens, an example of this is in the screenshot example. We may want to do one of the following:

  1. expose kwargs to the user both for rasterize() and for BaseTransformation.transform()
  2. don't do anything
  3. use the same approach as for labels -> no interpolation, no antialiasing
  • ...

When this is done we should update the test test_rasterize_raster(), which at the moment can't perform a pixel to pixel comparison (also because of this other issue #165).

Screenshot example.

This
image

becomes this (the offset is due to #165)
image

when doing a rasterization with the parameter target_unit_to_pixels = 2

@LucaMarconato
Copy link
Member Author

I would probably go for option 1.

Notices that the rasterization function could be used for allowing an easy implementation of aggergation when images and labels are not aligned (e.g. rotated) or not the same resolution. For this one we will probably need to carefully choose the appropriate kwargs, and maybe even do some kind of normalization (the user will not have to worry about this, we can do it inside our aggregation functions that call the rasterization internally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant