Kitware / itk-vtk-viewer

2D / 3D web image, mesh, and point set viewer using itk-wasm and vtk.js
https://kitware.github.io/itk-vtk-viewer/
BSD 3-Clause "New" or "Revised" License
210 stars 64 forks source link

feat(Zarr): Identify RGB RGBA pixel types #489

Open thewtex opened 2 years ago

thewtex commented 2 years ago

2D, uint8 pixel and 3 or 4 components -> Assume we want to render like an RGB / RGBA.

thewtex commented 2 years ago

@PaulHax I did not test this -- are any of the testing datasets we have relevant?

PaulHax commented 2 years ago

The removed logo.zarr matched that signature.

PaulHax commented 2 years ago

Swapped in this

const computePixelType = (components, arrayShape, componentType) => {
  // is 2D and unsigned 8 bit?  (arrayShape.get('z') may be 1)
  if ((arrayShape.get('z') ?? 1) === 1 && componentType === IntTypes.UInt8) {
    if (components === 3) return PixelTypes.RGB
    if (components === 4) return PixelTypes.RGBA
  }
  return components > 1 ? PixelTypes.VariableLengthVector : PixelTypes.Scalar
}

Here


  const componentType = getComponentType(info.pixelArrayMetadata.dtype)

  const pixelType = computePixelType(components, info.arrayShape, componentType)

  const imageType = {

gets me a logo.zarr like this: Screenshot from 2022-05-19 09-45-05

Just lines, like I was seeing before this last Zarr effort.