1 /*=========================================================================
4 Module: $RCSfile: vtkGdcmReader.cxx,v $
6 Date: $Date: 2007/05/30 15:11:16 $
7 Version: $Revision: 1.87 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 //-----------------------------------------------------------------------------
20 // //////////////////////////////////////////////////////////////
22 //===> Many users expect from vtkGdcmReader it 'orders' the images
23 // (that's the job of gdcm::SerieHelper ...)
24 // When user *knows* the files with same Serie UID
25 // have same sizes, same 'pixel' type, same color convention, ...
26 // the right way to proceed is as follow :
28 // gdcm::SerieHelper *sh= new gdcm::SerieHelper();
29 // // if user wants *not* to load some parts of the file headers
30 // sh->SetLoadMode(loadMode);
31 // // if user wants *not* to load some files
32 // sh->AddRestriction(group, element, value, operator);
33 // sh->AddRestriction( ...
34 // sh->SetDirectory(directoryWithImages);
36 // // if user wants to sort reverse order
37 // sh->SetSortOrderToReverse();
38 // // here, we suppose only the first Coherent File List is of interest
39 // gdcm::FileList *l = sh->GetFirstCoherentFileList();
40 // // if user is doesn't trust too much the files with same Serie UID
41 // if ( !sh->IsCoherent(l) )
42 // return; // not same sizes, same 'pixel' type -> stop
43 // sh->OrderFileList(l); // sort the list
45 // vtkGdcmReader *reader = vtkGdcmReader::New();
46 // // if user wants to modify pixel order (Mirror, TopDown, 90°Rotate, ...)
47 // // he has to supply the function that does the job
48 // // (a *very* simple example is given in vtkgdcmSerieViewer.cxx)
49 // reader->SetUserFunction (userSuppliedFunction);
50 // // to pass a 'Coherent File List' as produced by gdcm::SerieHelper
51 // reader->SetCoherentFileList(l);
54 // WARNING TODO CLEANME
55 // Actual limitations of this code
56 // when a Coherent File List from SerieHelper is not used (bad idea :-(
58 // //////////////////////////////////////////////////////////////
60 #include "gdcmFileHelper.h"
62 #include "gdcmSerieHelper.h" // for ImagePositionPatientOrdering()
64 #include "vtkGdcmReader.h"
65 #include "gdcmDebug.h"
66 #include "gdcmCommon.h"
68 #include <vtkObjectFactory.h>
69 #include <vtkImageData.h>
70 #include <vtkPointData.h>
71 #include <vtkLookupTable.h>
73 vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.87 $")
74 vtkStandardNewMacro(vtkGdcmReader)
76 //-----------------------------------------------------------------------------
77 // Constructor / Destructor
78 vtkGdcmReader::vtkGdcmReader()
80 this->LookupTable = NULL;
81 this->AllowLookupTable = false;
82 this->AllowLightChecking = false;
83 this->LoadMode = gdcm::LD_ALL; // Load everything (possible values :
87 this->CoherentFileList = 0;
88 this->UserFunction = 0;
91 // this->Execution=false; // For VTK5.0
94 vtkGdcmReader::~vtkGdcmReader()
96 this->RemoveAllFileName();
97 this->InternalFileNameList.clear();
99 this->LookupTable->Delete();
102 //-----------------------------------------------------------------------------
104 void vtkGdcmReader::PrintSelf(ostream &os, vtkIndent indent)
106 this->Superclass::PrintSelf(os,indent);
107 os << indent << "Filenames : " << endl;
108 vtkIndent nextIndent = indent.GetNextIndent();
109 for (std::list<std::string>::iterator it = FileNameList.begin();
110 it != FileNameList.end();
113 os << nextIndent << it->c_str() << endl ;
117 //-----------------------------------------------------------------------------
120 * Remove all files from the list of images to read.
122 void vtkGdcmReader::RemoveAllFileName(void)
124 this->FileNameList.clear();
129 * Adds a file name to the list of images to read.
131 void vtkGdcmReader::AddFileName(const char* name)
133 // We need to bypass the const pointer [since list<>.push_bash() only
134 // takes a char* (but not a const char*)] by making a local copy:
135 this->FileNameList.push_back(name);
140 * Sets up a filename to be read.
142 void vtkGdcmReader::SetFileName(const char *name)
144 vtkImageReader2::SetFileName(name);
145 // Since we maintain a list of filenames, when building a volume,
146 // (see vtkGdcmReader::AddFileName), we additionaly need to purge
147 // this list when we manually positionate the filename.
148 vtkDebugMacro(<< "Clearing all files given with AddFileName");
149 this->FileNameList.clear();
153 //-----------------------------------------------------------------------------
156 * Configure the output e.g. WholeExtent, spacing, origin, scalar type...
158 void vtkGdcmReader::ExecuteInformation()
160 // if(this->Execution) // For VTK5.0
163 // this->Execution=true; // end For VTK5.0
164 this->RemoveAllInternalFile();
165 if(this->MTime>this->fileTime)
167 this->TotalNumberOfPlanes = 0;
169 if ( this->CoherentFileList != 0 )
171 this->UpdateFileInformation();
175 this->BuildFileListFromPattern();
176 this->LoadFileInformation();
179 if ( this->TotalNumberOfPlanes == 0)
181 vtkErrorMacro(<< "File set is not coherent. Exiting...");
185 // if the user has not set the extent, but has set the VOI
186 // set the z axis extent to the VOI z axis
187 if (this->DataExtent[4]==0 && this->DataExtent[5] == 0 &&
188 (this->DataVOI[4] || this->DataVOI[5]))
190 this->DataExtent[4] = this->DataVOI[4];
191 this->DataExtent[5] = this->DataVOI[5];
194 // When the user has set the VOI, check it's coherence with the file content.
195 if (this->DataVOI[0] || this->DataVOI[1] ||
196 this->DataVOI[2] || this->DataVOI[3] ||
197 this->DataVOI[4] || this->DataVOI[5])
199 if ((this->DataVOI[0] < 0) ||
200 (this->DataVOI[1] >= this->NumColumns) ||
201 (this->DataVOI[2] < 0) ||
202 (this->DataVOI[3] >= this->NumLines) ||
203 (this->DataVOI[4] < 0) ||
204 (this->DataVOI[5] >= this->TotalNumberOfPlanes ))
206 vtkWarningMacro(<< "The requested VOI is larger than expected extent.");
207 this->DataVOI[0] = 0;
208 this->DataVOI[1] = this->NumColumns - 1;
209 this->DataVOI[2] = 0;
210 this->DataVOI[3] = this->NumLines - 1;
211 this->DataVOI[4] = 0;
212 this->DataVOI[5] = this->TotalNumberOfPlanes - 1;
217 this->DataExtent[0] = 0;
218 this->DataExtent[1] = this->NumColumns - 1;
219 this->DataExtent[2] = 0;
220 this->DataExtent[3] = this->NumLines - 1;
221 this->DataExtent[4] = 0;
222 this->DataExtent[5] = this->TotalNumberOfPlanes - 1;
224 // We don't need to set the Endian related stuff (by using
225 // this->SetDataByteOrderToBigEndian() or SetDataByteOrderToLittleEndian()
226 // since the reading of the file is done by gdcm.
227 // But we do need to set up the data type for downstream filters:
228 if ( ImageType == "8U" )
230 vtkDebugMacro(<< "8 bits unsigned image");
231 this->SetDataScalarTypeToUnsignedChar();
233 else if ( ImageType == "8S" )
235 vtkErrorMacro(<< "Cannot handle 8 bit signed files");
238 else if ( ImageType == "16U" )
240 vtkDebugMacro(<< "16 bits unsigned image");
241 this->SetDataScalarTypeToUnsignedShort();
243 else if ( ImageType == "16S" )
245 vtkDebugMacro(<< "16 bits signed image");
246 this->SetDataScalarTypeToShort();
248 else if ( ImageType == "32U" )
250 vtkDebugMacro(<< "32 bits unsigned image");
251 vtkDebugMacro(<< "WARNING: forced to signed int !");
252 this->SetDataScalarTypeToInt();
254 else if ( ImageType == "32S" )
256 vtkDebugMacro(<< "32 bits signed image");
257 this->SetDataScalarTypeToInt();
259 else if ( ImageType == "FD" )
261 vtkDebugMacro(<< "64 bits Double image");
262 this->SetDataScalarTypeToDouble();
264 //Set number of scalar components:
265 this->SetNumberOfScalarComponents(this->NumComponents);
267 this->fileTime=this->MTime;
270 this->Superclass::ExecuteInformation();
272 //this->GetOutput()->SetUpdateExtentToWholeExtent();// For VTK5.0
273 //this->BuildData(this->GetOutput());
275 //this->Execution=false;
276 //this->RemoveAllInternalFile(); // End For VTK5.0
280 * Update => ouput->Update => UpdateData => Execute => ExecuteData
281 * (see vtkSource.cxx for last step).
282 * This function (redefinition of vtkImageReader::ExecuteData, see
283 * VTK/IO/vtkImageReader.cxx) reads a data from a file. The data
284 * extent/axes are assumed to be the same as the file extent/order.
286 void vtkGdcmReader::ExecuteData(vtkDataObject *output)
288 vtkImageData *data=vtkImageData::SafeDownCast(output);
289 data->SetExtent(this->DataExtent);
291 /* if ( CoherentFileList != 0 ) // When a list of names is passed
293 if (this->CoherentFileList->empty())
295 vtkErrorMacro(<< "Coherent File List must have at least a valid File*.");
299 else if (this->InternalFileNameList.empty())
301 vtkErrorMacro(<< "A least a valid FileName must be specified.");
306 // data->AllocateScalars(); // For VTK5.0
307 // if (this->UpdateExtentIsEmpty(output))
311 //} // end For VTK5.0
313 data->AllocateScalars(); // For VTK5.0
314 if (this->UpdateExtentIsEmpty(output))
319 //void vtkGdcmReader::BuildData(vtkDataObject *output) // For VTK5.0
321 // vtkImageData *data = this->AllocateOutputData(output); // end For VTK5.0
323 data->GetPointData()->GetScalars()->SetName("DicomImage-Volume");
325 // Test if output has valid extent
326 // Prevent memory errors
327 if((this->DataExtent[1]-this->DataExtent[0]>=0) &&
328 (this->DataExtent[3]-this->DataExtent[2]>=0) &&
329 (this->DataExtent[5]-this->DataExtent[4]>=0))
331 // The memory size for a full stack of images of course depends
332 // on the number of planes and the size of each image:
333 //size_t StackNumPixels = this->NumColumns * this->NumLines
334 // * this->TotalNumberOfPlanes * this->NumComponents;
335 //size_t stack_size = StackNumPixels * this->PixelSize; //not used
336 // Allocate pixel data space itself.
338 // Variables for the UpdateProgress. We shall use 50 steps to signify
339 // the advance of the process:
340 unsigned long UpdateProgressTarget = (unsigned long) ceil (this->NumLines
341 * this->TotalNumberOfPlanes
343 // The actual advance measure:
344 unsigned long UpdateProgressCount = 0;
346 // Filling the allocated memory space with each image/volume:
348 size_t size = this->NumColumns * this->NumLines * this->NumPlanes
349 * data->GetScalarSize() * this->NumComponents;
350 unsigned char *Dest = (unsigned char *)data->GetScalarPointer();
351 for (std::vector<gdcm::File* >::iterator it = InternalFileList.begin();
352 it != InternalFileList.end();
355 this->LoadImageInMemory(*it, Dest,
356 UpdateProgressTarget,
357 UpdateProgressCount);
361 this->RemoveAllInternalFile(); // For VTK5.0
365 * vtkGdcmReader can have the file names specified through two ways:
366 * (1) by calling the vtkImageReader2::SetFileName(), SetFilePrefix() and
368 * (2) By successive calls to vtkGdcmReader::AddFileName()
369 * When the first method was used by caller we need to update the local
372 void vtkGdcmReader::BuildFileListFromPattern()
374 this->RemoveAllInternalFileName();
376 // Test miscellanous cases
377 if ((! this->FileNameList.empty()) && this->FileName )
379 vtkErrorMacro(<< "Both AddFileName and SetFileName schemes were used");
380 vtkErrorMacro(<< "No images loaded ! ");
384 if ((! this->FileNameList.empty()) && this->FilePrefix )
386 vtkErrorMacro(<< "Both AddFileName and SetFilePrefix schemes were used");
387 vtkErrorMacro(<< "No images loaded ! ");
391 if (this->FileName && this->FilePrefix)
393 vtkErrorMacro(<< "Both SetFileName and SetFilePrefix schemes were used");
394 vtkErrorMacro(<< "No images loaded ! ");
398 // Create the InternalFileNameList
399 if (! this->FileNameList.empty() )
401 vtkDebugMacro(<< "Using the AddFileName specified files");
402 this->InternalFileNameList=this->FileNameList;
406 if (!this->FileName && !this->FilePrefix)
408 vtkErrorMacro(<< "FileNames are not set. Either use AddFileName() or");
409 vtkErrorMacro(<< "specify a FileName or FilePrefix.");
415 // Single file loading (as given with ::SetFileName()):
416 // Case of multi-frame file considered here
417 this->ComputeInternalFileName(this->DataExtent[4]);
418 vtkDebugMacro(<< "Adding file " << this->InternalFileName);
419 this->AddInternalFileName(this->InternalFileName);
423 // Multi file loading (as given with ::SetFilePattern()):
424 for (int idx = this->DataExtent[4]; idx <= this->DataExtent[5]; ++idx)
426 this->ComputeInternalFileName(idx);
427 vtkDebugMacro(<< "Adding file " << this->InternalFileName);
428 this->AddInternalFileName(this->InternalFileName);
434 * Load all the files and set it in the InternalFileList
435 * For each file, the readability and the coherence of image caracteristics
436 * are tested. If an image doesn't agree the required specifications, it
437 * isn't considered and no data will be set for the planes corresponding
440 * The source of this work is the list of file name generated by the
441 * BuildFileListFromPattern method
443 void vtkGdcmReader::LoadFileInformation()
446 bool foundReference=false;
450 for (std::list<std::string>::iterator filename = InternalFileNameList.begin();
451 filename != InternalFileNameList.end();
454 // check for file readability
456 fp = fopen(filename->c_str(),"rb");
459 vtkErrorMacro(<< "Unable to open file " << filename->c_str());
460 vtkErrorMacro(<< "Removing this file from read files: "
461 << filename->c_str());
463 InternalFileList.push_back(file);
469 file=gdcm::File::New();
470 file->SetLoadMode( LoadMode );
471 file->SetFileName(filename->c_str() );
474 // Test the Dicom file readability
475 if(!file->IsReadable())
477 vtkErrorMacro(<< "Gdcm cannot parse file " << filename->c_str());
478 vtkErrorMacro(<< "Removing this file from read files: "
479 << filename->c_str());
482 InternalFileList.push_back(file);
486 // Test the Pixel Type recognition
487 type = file->GetPixelType();
488 if ( (type != "8U") && (type != "8S")
489 && (type != "16U") && (type != "16S")
490 && (type != "32U") && (type != "32S") )
492 vtkErrorMacro(<< "Bad File Type for file " << filename->c_str() << "\n"
493 << " File type found : " << type.c_str()
494 << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n"
495 << " Removing this file from read files");
498 InternalFileList.push_back(file);
502 // Test the image informations
505 foundReference = true;
506 GetFileInformation(file);
508 vtkDebugMacro(<< "This file taken as coherence reference:"
509 << filename->c_str());
510 vtkDebugMacro(<< "Image dimensions of reference file as read from Gdcm:"
511 << this->NumColumns << " " << this->NumLines << " "
514 else if(!TestFileInformation(file))
520 InternalFileList.push_back(file);
525 * Update the file informations.
526 * This works exactly like LoadFileInformation, but the source of work
527 * is the list of coherent files
529 void vtkGdcmReader::UpdateFileInformation()
531 this->InternalFileList=*(this->CoherentFileList);
534 for(gdcmFileList::iterator it=InternalFileList.begin();
535 it!=InternalFileList.end();
540 GetFileInformation(*it);
547 * Get the informations from a file.
548 * These informations are required to specify the output image
551 void vtkGdcmReader::GetFileInformation(gdcm::File *file)
553 // Get the image caracteristics
554 this->NumColumns = file->GetXSize();
555 this->NumLines = file->GetYSize();
556 this->NumPlanes = file->GetZSize();
558 if (CoherentFileList == 0)
559 this->TotalNumberOfPlanes = this->NumPlanes*InternalFileNameList.size();
561 this->TotalNumberOfPlanes = this->NumPlanes*CoherentFileList->size();
563 this->ImageType = file->GetPixelType();
564 this->PixelSize = file->GetPixelSize();
566 this->DataSpacing[0] = file->GetXSpacing();
567 this->DataSpacing[1] = file->GetYSpacing();
569 // Most of the file headers have NO z spacing
570 // It must be calculated from the whole gdcm::Serie (if any)
571 // using Jolinda Smith's algoritm.
572 // see gdcm::SerieHelper::ImagePositionPatientOrdering()
573 if (CoherentFileList == 0)
574 this->DataSpacing[2] = file->GetZSpacing();
577 // Just because OrderFileList() is a member of gdcm::SerieHelper
578 // we need to instanciate sh.
579 gdcm::SerieHelper *sh = gdcm::SerieHelper::New();
580 sh->OrderFileList(CoherentFileList); // calls ImagePositionPatientOrdering()
581 DataSpacing[2] = sh->GetZSpacing();
585 // Get the image data caracteristics
586 if( file->HasLUT() && this->AllowLookupTable )
588 // I could raise an error is AllowLookupTable is on and HasLUT() off
589 this->NumComponents = file->GetNumberOfScalarComponentsRaw();
593 this->NumComponents = file->GetNumberOfScalarComponents(); //rgb or mono
598 * When more than one filename is specified (i.e. we expect loading
599 * a stack or volume) we need to check that the corresponding images/volumes
600 * to be loaded are coherent i.e. to make sure:
601 * - they all share the same X dimensions
602 * - they all share the same Y dimensions
603 * - they all share the same ImageType ( 8 bit signed, or unsigned...)
605 * Eventually, we emit a warning when all the files do NOT share the
606 * Z dimension, since we can still build a stack but the
607 * files are not coherent in Z, which is probably a source a trouble...
608 * When files are not readable (either the file cannot be opened or
609 * because gdcm cannot parse it), they are flagged as "GDCM_UNREADABLE".
610 * This method returns the total number of planar images to be loaded
611 * (i.e. an image represents one plane, but a volume represents many planes)
614 * Test the coherent informations of the file with the reference informations
615 * used as image caracteristics. The tested informations are :
616 * - they all share the same X dimensions
617 * - they all share the same Y dimensions
618 * - they all share the same Z dimensions
619 * - they all share the same number of components
620 * - they all share the same ImageType ( 8 bit signed, or unsigned...)
622 * \return True if the file match, False otherwise
624 bool vtkGdcmReader::TestFileInformation(gdcm::File *file)
626 int numColumns = file->GetXSize();
627 int numLines = file->GetYSize();
628 int numPlanes = file->GetZSize();
630 unsigned int pixelSize = file->GetPixelSize();
632 if( file->HasLUT() && this->AllowLookupTable )
633 numComponents = file->GetNumberOfScalarComponentsRaw();
635 numComponents = file->GetNumberOfScalarComponents(); //rgb or mono
637 if( numColumns != this->NumColumns )
639 vtkErrorMacro(<< "File X value doesn't match with the previous ones: "
640 << file->GetFileName().c_str()
641 << ". Found " << numColumns << ", must be "
642 << this->NumColumns);
645 if( numLines != this->NumLines )
647 vtkErrorMacro(<< "File Y value doesn't match with the previous ones: "
648 << file->GetFileName().c_str()
649 << ". Found " << numLines << ", must be "
653 if( numPlanes != this->NumPlanes )
655 vtkErrorMacro(<< "File Z value doesn't match with the previous ones: "
656 << file->GetFileName().c_str()
657 << ". Found " << numPlanes << ", must be "
661 if( numComponents != this->NumComponents )
663 vtkErrorMacro(<< "File Components count doesn't match with the previous ones: "
664 << file->GetFileName().c_str()
665 << ". Found " << numComponents << ", must be "
666 << this->NumComponents);
669 if( pixelSize != this->PixelSize )
671 vtkErrorMacro(<< "File pixel size doesn't match with the previous ones: "
672 << file->GetFileName().c_str()
673 << ". Found " << pixelSize << ", must be "
681 //-----------------------------------------------------------------------------
684 * Remove all file names to the internal list of images to read.
686 void vtkGdcmReader::RemoveAllInternalFileName(void)
688 this->InternalFileNameList.clear();
692 * Adds a file name to the internal list of images to read.
694 void vtkGdcmReader::AddInternalFileName(const char *name)
696 char *LocalName = new char[strlen(name) + 1];
697 strcpy(LocalName, name);
698 this->InternalFileNameList.push_back(LocalName);
703 * Remove all file names to the internal list of images to read.
705 void vtkGdcmReader::RemoveAllInternalFile(void)
709 for(gdcmFileList::iterator it=InternalFileList.begin();
710 it!=InternalFileList.end();
716 this->InternalFileList.clear();
719 void vtkGdcmReader::IncrementProgress(const unsigned long updateProgressTarget,
720 unsigned long &updateProgressCount)
722 // Update progress related for bad files:
723 updateProgressCount += this->NumLines;
724 if (updateProgressTarget > 0)
726 if (!(updateProgressCount%updateProgressTarget))
728 this->UpdateProgress(
729 updateProgressCount/(50.0*updateProgressTarget));
735 * Loads the contents of the image/volume contained by char *fileName at
736 * the dest memory address. Returns the size of the data loaded.
738 /*void vtkGdcmReader::LoadImageInMemory(
739 std::string fileName,
741 const unsigned long updateProgressTarget,
742 unsigned long &updateProgressCount)
744 vtkDebugMacro(<< "Copying to memory image [" << fileName.c_str() << "]");
747 f = new gdcm::File();
748 f->SetLoadMode( LoadMode );
749 f->SetFileName( fileName.c_str() );
752 LoadImageInMemory(f,dest,
753 updateProgressTarget,
754 updateProgressCount);
759 * Loads the contents of the image/volume contained by gdcm::File* f at
760 * the Dest memory address. Returns the size of the data loaded.
761 * \ param f File to consider. NULL if the file must be skiped
762 * \remarks Assume that if (f != NULL) then its caracteristics match
763 * with the previous ones
765 void vtkGdcmReader::LoadImageInMemory(
768 const unsigned long updateProgressTarget,
769 unsigned long &updateProgressCount)
774 gdcm::FileHelper *fileH = gdcm::FileHelper::New( f );
775 fileH->SetUserFunction( UserFunction );
777 int numColumns = f->GetXSize();
778 int numLines = f->GetYSize();
779 int numPlanes = f->GetZSize();
782 if( f->HasLUT() && this->AllowLookupTable )
783 numComponents = f->GetNumberOfScalarComponentsRaw();
785 numComponents = f->GetNumberOfScalarComponents(); //rgb or mono
786 vtkDebugMacro(<< "numComponents:" << numComponents);
787 vtkDebugMacro(<< "Copying to memory image [" << f->GetFileName().c_str() << "]");
790 // If the data structure of vtk for image/volume representation
791 // were straigthforwards the following would be enough:
792 // GdcmFile.GetImageDataIntoVector((void*)Dest, size);
793 // But vtk chooses to invert the lines of an image, that is the last
794 // line comes first (for some axis related reasons?). Hence we need
795 // to load the image line by line, starting from the end.
797 int lineSize = NumComponents * numColumns * f->GetPixelSize();
798 int planeSize = lineSize * numLines;
802 if( fileH->GetFile()->HasLUT() && AllowLookupTable )
804 // to avoid bcc 5.5 w
805 /*size = */ fileH->GetImageDataSize();
806 src = (unsigned char*) fileH->GetImageDataRaw();
807 unsigned char *lut = (unsigned char*) fileH->GetLutRGBA();
809 if(!this->LookupTable)
811 this->LookupTable = vtkLookupTable::New();
814 this->LookupTable->SetNumberOfTableValues(256);
815 for (int tmp=0; tmp<256; tmp++)
817 this->LookupTable->SetTableValue(tmp,
818 (float)lut[4*tmp+0]/255.0,
819 (float)lut[4*tmp+1]/255.0,
820 (float)lut[4*tmp+2]/255.0,
823 this->LookupTable->SetRange(0,255);
824 vtkDataSetAttributes *a = this->GetOutput()->GetPointData();
825 a->GetScalars()->SetLookupTable(this->LookupTable);
830 //size = fileH->GetImageDataSize();
831 // useless - just an accessor; 'size' unused
832 src = (unsigned char*)fileH->GetImageData();
835 unsigned char *dst = dest + planeSize - lineSize;
836 for (int plane = 0; plane < numPlanes; plane++)
838 for (int line = 0; line < numLines; line++)
840 // Copy one line at proper destination:
841 memcpy((void*)dst, (void*)src, lineSize);
844 // Update progress related:
845 if (!(updateProgressCount%updateProgressTarget))
847 this->UpdateProgress(
848 updateProgressCount/(50.0*updateProgressTarget));
850 updateProgressCount++;
852 dst += 2 * planeSize;
858 //-----------------------------------------------------------------------------