Commit 32f5e6d9 authored by David Gobbi's avatar David Gobbi

Fix blank slices that appear in some TIFF volumes.

The logic for skipping subfiles that aren't part of the primary image
(e.g. subfiles that contain reduced-resolution slices) was incorrect.
When the reader encountered such subfiles, it would simply move on to
the next slice of the image, without setting the voxel values for the
current slice.  Now, the "slice" counter and the "page" counter are
distinct from one another, since not all pages become image slices.
parent 7a0508d9
......@@ -863,13 +863,11 @@ void vtkTIFFReader::ReadVolume(T* buffer)
{
int width = this->InternalImage->Width;
int height = this->InternalImage->Height;
int samplesPerPixel = this->InternalImage->SamplesPerPixel;
unsigned int npages = this->InternalImage->NumberOfPages;
if (this->InternalImage->SubFiles > 0)
{
// See ExecuteInformation
npages = this->InternalImage->SubFiles;
}
// counter for slices (not every page is a slice)
unsigned int slice = 0;
for (unsigned int page = 0; page < npages; ++page)
{
this->UpdateProgress(static_cast<double>(page + 1) / npages);
......@@ -888,10 +886,10 @@ void vtkTIFFReader::ReadVolume(T* buffer)
}
// if we have a Zeiss image meaning that the SamplesPerPixel is 2
if (this->InternalImage->SamplesPerPixel == 2)
if (samplesPerPixel == 2)
{
T* volume = buffer;
volume += width * height * this->InternalImage->SamplesPerPixel * page;
volume += width * height * slice * samplesPerPixel;
this->ReadTwoSamplesPerPixelImage(volume, width, height);
break;
}
......@@ -909,7 +907,7 @@ void vtkTIFFReader::ReadVolume(T* buffer)
const bool flip = this->InternalImage->Orientation != ORIENTATION_TOPLEFT;
T* fimage = buffer;
fimage += width * height * 4 * page;
fimage += width * height * 4 * slice;
for (int yy = 0; yy < height; ++yy)
{
uint32* ssimage;
......@@ -945,7 +943,7 @@ void vtkTIFFReader::ReadVolume(T* buffer)
case vtkTIFFReader::PALETTE_GRAYSCALE:
{
T* volume = buffer;
volume += width * height * this->InternalImage->SamplesPerPixel * page;
volume += width * height * slice * samplesPerPixel;
this->ReadGenericImage(volume, width, height);
break;
}
......@@ -953,6 +951,9 @@ void vtkTIFFReader::ReadVolume(T* buffer)
return;
}
}
// advance to next slice
slice++;
TIFFReadDirectory(this->InternalImage->Image);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment