As pointed out by the ECVL team during the DeepHealth Winter School, if users want to display images that have been converted to numpy arrays, some transformations are likely required. This is due to the fact that python libraries that display numpy arrays as images use different conventions than those used by ECVL: the formers expect an RGB image in yxc layout, while ECVL, by default, uses BGR and xyc. We should add a note to the docs, suggesting to apply ChangeColorSpace and RearrangeChannels to the image.
NOTE:
I initially suspected this had something to do with the fact that ECVL images -- and thus numpy arrays obtained by converting them -- have a column-major (aka fortran-style) internal memory layout (see strides computation), while numpy arrays by default have a row-major (or c-style) layout:
However, this is actually not an issue, since numpy also supports column-major layouts (as shown above) and that's internal: the contents of the array don't change, but only how N-dimensional indices are internally handled to address the elements. The reason for rotated / flipped images is the difference in the channel order convention, as stated above.
As pointed out by the ECVL team during the DeepHealth Winter School, if users want to display images that have been converted to numpy arrays, some transformations are likely required. This is due to the fact that python libraries that display numpy arrays as images use different conventions than those used by ECVL: the formers expect an RGB image in
yxc
layout, while ECVL, by default, uses BGR andxyc
. We should add a note to the docs, suggesting to applyChangeColorSpace
andRearrangeChannels
to the image.NOTE:
I initially suspected this had something to do with the fact that ECVL images -- and thus numpy arrays obtained by converting them -- have a column-major (aka fortran-style) internal memory layout (see strides computation), while numpy arrays by default have a row-major (or c-style) layout:
However, this is actually not an issue, since numpy also supports column-major layouts (as shown above) and that's internal: the contents of the array don't change, but only how N-dimensional indices are internally handled to address the elements. The reason for rotated / flipped images is the difference in the channel order convention, as stated above.
CC: @prittt @lauracanalini