How to tell if a vtkImageData object contains any pixel/voxel data

What is the most straight-forward way to determine whether a vtkImageData object is “empty”. In other words, whether or not it contains any pixel/voxel data?
Thank you,
Michelle K.

What’s with GetNumberOfCells?

In 3D Slicer, we usually check (extent[0] <= extent[1] && extent[2] <= extent[3] && extent[4] <= extent[5]) . This is what vtkImageData::GetNumberOfCells() computes, too.

Even if the extent is non-empty, it is still possible that voxel data is not allocated yet, so then we also need to check (image->GetPointData() != nullptr) && (imageDataScalar->GetPointData()->GetScalars() != nullptr). This is particularly important, because at many places in VTK, GetPointData()->GetScalars() is called without checking if GetPointData() != nullptr, leading to crashes if you set an empty image as input.

This is what I was looking for. Thanks Andras!

Thanks, Ronald.