Skip to content

Pixel shift in render_images #216

@quentinblampey

Description

@quentinblampey

Hello,

When plotting an image, it seems that there is a 0.5-pixel shift. This is not visible for large images but becomes very visible if we zoom in, and, mostly, it gets amplified with transformations (a Scale(1000, 1000) transformation will create a shift of 500 pixels).

Minimum reproducible example

import numpy as np
import spatialdata_plot
import spatialdata
from spatialdata.models import Image2DModel
from spatial_image import SpatialImage

image = SpatialImage(np.zeros((1, 4, 8)), dims=("c", "y", "x"))
image = Image2DModel.parse(image)

sdata = spatialdata.SpatialData(images={"image": image})

sdata.pl.render_images().pl.show()

It should render this image (we see that the image is not reaching (8, 4), but (7.5, 3.5) instead):
image

Maybe I did something wrong with the x-coords or y-coords? Should we update the coords or they should be fine by default?

Sorry for such a minor issue...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions