/*========================================================================= Program: GDCM (Grassroots DICOM). A DICOM library Copyright (c) 2006-2011 Mathieu Malaterre All rights reserved. See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // This work was realised during the GSOC 2011 by Manoj Alwani #include "gdcmStreamImageReader.h" #include "gdcmFileMetaInformation.h" #include "gdcmSystem.h" #include "gdcmFilename.h" #include "gdcmByteSwap.h" #include "gdcmTrace.h" #include "gdcmTesting.h" #include "gdcmImageHelper.h" #include "gdcmImageReader.h" #include "gdcmImage.h" #include "gdcmMediaStorage.h" #include "gdcmRAWCodec.h" #include "gdcmJPEGLSCodec.h" #include "gdcmUIDGenerator.h" #include "gdcmStreamImageWriter.h" #include "gdcmAttribute.h" #include "gdcmFile.h" #include "gdcmTag.h" bool StreamImageRead(gdcm::StreamImageWriter & theStreamWriter, const char* filename, const char* outfilename, int resolution) { gdcm::StreamImageReader reader; reader.SetFileName( filename ); if (!reader.ReadImageInformation()) { std::cerr << "unable to read image information" << std::endl; return 1; //unable to read tags as expected. } //let's be tricky; each image will be read in portions, first the top half, then the bottom //that way, we can test how the stream handles fragmentation of the data //we could also loop this to get various different size combinations, but I'm not sure //that's useful, yet. std::vector extent = gdcm::ImageHelper::GetDimensionsValue(reader.GetFile()); // std::cout << extent[0]; //at this point, these values aren't used, but may be in the future //unsigned short xmin = 0; //unsigned short xmax = extent[0]; //unsigned short ymin = 0; //unsigned short ymax = extent[1]; //unsigned short zmin = 0; //unsigned short zmax = extent[2]; std::cout<< "\n Row: "< Number_Of_Frames = {1}; ds.Insert( Number_Of_Frames.GetAsDataElement() ); gdcm::Attribute<0x0028,0x0010> row = {extent[0]/a};// ds.Insert( row.GetAsDataElement() ); gdcm::Attribute<0x0028,0x0011> col = {extent[1]/a};// ds.Insert( col.GetAsDataElement() ); gdcm::Attribute<0x0028,0x0100> at = {8}; ds.Insert( at.GetAsDataElement() ); gdcm::Attribute<0x0028,0x0002> at1 = {1};// ds.Insert( at1.GetAsDataElement() ); gdcm::Attribute<0x0028,0x0101> at2 = {8}; ds.Insert( at2.GetAsDataElement() ); gdcm::Attribute<0x0028,0x0102> at3 = {7}; ds.Insert( at3.GetAsDataElement() ); /* ds1.Remove( gdcm::Tag(0x0028,0x0008) ); gdcm::Attribute<0x0028,0x0008> Number_Of_Frames = {1}; ds1.Insert( Number_Of_Frames.GetAsDataElement() ); */ theStreamWriter.SetFile(file); if (!theStreamWriter.WriteImageInformation()) { std::cerr << "unable to write image information" << std::endl; return 1; //the CanWrite function should prevent getting here, else, //that's a test failure } std::vector extent1 = gdcm::ImageHelper::GetDimensionsValue(file); unsigned short xmax = extent1[0]; unsigned short ymax = extent1[1]; unsigned short theChunkSize = 1; unsigned short ychunk = extent1[1]/theChunkSize; //go in chunk sizes of theChunkSize unsigned short zmax = 1; std::cout<< "\n Row: "< ymax) nexty = ymax; theStreamWriter.DefinePixelExtent(0, xmax, y, nexty, z, z+1); unsigned long len = theStreamWriter.DefineProperBufferLength(); std::cout << "\n" <