Skip to content

Incorrect shape and strides after load_image() #22

@ukoethe

Description

@ukoethe

ximage-io claims to use the shape convention WIDTH x HEIGHT x CHANNELS (see http://xtensor-io.readthedocs.io/en/latest/api_reference.html#images) along with the usual c-order strides (increasing from back to front). However, this is wrong.

All file formats store images such that the WIDTH axis has smaller stride than the HEIGHT axis, and xtensor-io reads the memory unchanged. This means that the shape must be HEIGHT x WIDTH x CHANNELS with corresponding strides. All other libraries that follow the c-order convention use this shape, see for example scikit-image. You can easily verify the error with a simple program:

        auto in  = xt::load_image("color_image.tif");
        for(int y=0; y<in.shape()[1]; ++y)
        {
            in(100, y, 1) = 255;
        }
        xt::dump_image("result.tif", in);

This should draw a vertical line, but actually draws a horizontal one.

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