const char* filename, const char* outfilename, int resolution)
{
{
std::cerr << "unable to read image information" << std::endl;
return 1;
}
std::vector<unsigned int> extent =
std::cout<< "\n Row: "<<extent[0] <<"\n Col :"<< extent[1]<< "\n Resolution :"<< extent[2] << std::endl;
int a =1;
for (int i=1; i<=(extent[2]-resolution);++i)
a = a*2;
char* finalBuffer = new char[len];
memset(finalBuffer, 0, sizeof(char)*len);
{
bool result = reader.
Read(finalBuffer, len);
if( !result )
{
std::cout << "res2 failure:" << filename << std::endl;
delete [] finalBuffer;
return 1;
}
else
{
std::cout<< "Able to read";
}
}
else
{
std::cerr<< "Not able to put in buffer"<< std::endl;
}
const char mystr[] = "MONOCHROME2 ";
{
std::cerr << "unable to write image information" << std::endl;
return 1;
}
unsigned short xmax = extent1[0];
unsigned short ymax = extent1[1];
unsigned short theChunkSize = 1;
unsigned short ychunk = extent1[1]/theChunkSize;
unsigned short zmax = 1;
std::cout<< "\n Row: "<<extent1[0] <<"\n Col :"<< extent1[1]<< "\n Resolution :"<< extent1[2] << std::endl;
if (xmax == 0 || ymax == 0)
{
std::cerr << "Image has no size, unable to write zero-sized image." << std::endl;
return 0;
}
int z, y, nexty;
unsigned long prevLen = 0;
for (z = 0; z < zmax; ++z){
for (y = 0; y < ymax; y += ychunk){
nexty = y + ychunk;
if (nexty > ymax) nexty = ymax;
std::cout << "\n" <<len;
char* finalBuffer1 = new char[len];
memcpy(finalBuffer1, &(finalBuffer[prevLen]), len);
std::cout << "\nable to write";
if (!theStreamWriter.
Write(finalBuffer1, len)){
std::cerr << "writing failure:" << "output.dcm" << " at y = " << y << " and z= " << z << std::endl;
delete [] finalBuffer1;
delete [] finalBuffer;
return 1;
}
delete [] finalBuffer1;
prevLen += len;
}
}
delete [] finalBuffer;
std::cout << "all is set";
return true;
}
int main(int argc, char *argv[])
{
if( argc < 3 )
{
std::cerr << argv[0] << " input.dcm output.dcm Resolution" << std::endl;
return 1;
}
const char *filename = argv[1];
const char *outfilename = argv[2];
char *res = argv[3];
int resolution = atoi(res);
std::ofstream of;
of.open( outfilename, std::ios::out | std::ios::binary );
if(!StreamImageRead( theStreamWriter, filename, outfilename, resolution))
return 1;
uint16_t firstTag1 = 0xfffe;
uint16_t secondTag1 = 0xe0dd;
uint32_t thirdTag1 = 0x00000000;
const int theBufferSize1 = 2*sizeof(uint16_t)+sizeof(uint32_t);
char* tmpBuffer2 = new char[theBufferSize1];
memcpy(&(tmpBuffer2[0]), &firstTag1, sizeof(uint16_t));
memcpy(&(tmpBuffer2[sizeof(uint16_t)]), &secondTag1, sizeof(uint16_t));
memcpy(&(tmpBuffer2[2*sizeof(uint16_t)]), &thirdTag1, sizeof(uint32_t));
assert( of && !of.eof() && of.good() );
of.write(tmpBuffer2, theBufferSize1);
of.flush();
assert( of );
return 0;
}
Attribute class This class use template metaprograming tricks to let the user know when the template ...
Definition gdcmAttribute.h:86
DataElement GetAsDataElement() const
Definition gdcmAttribute.h:183
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
void SetByteValue(const char *array, VL length)
Definition gdcmDataElement.h:126
void SetVR(VR const &vr)
Definition gdcmDataElement.h:88
Class to represent a Data Set (which contains Data Elements)
Definition gdcmDataSet.h:56
void Insert(const DataElement &de)
Definition gdcmDataSet.h:128
a DICOM File
Definition gdcmFile.h:34
const DataSet & GetDataSet() const
Get Data Set.
Definition gdcmFile.h:57
const FileMetaInformation & GetHeader() const
Get File Meta Information.
Definition gdcmFile.h:48
static std::vector< unsigned int > GetDimensionsValue(const File &f)
StreamImageReader.
Definition gdcmStreamImageReader.h:39
void DefinePixelExtent(uint16_t inXMin, uint16_t inXMax, uint16_t inYMin, uint16_t inYMax, uint16_t inZMin=0, uint16_t inZMax=1)
virtual bool ReadImageInformation()
bool Read(char *inReadBuffer, const std::size_t &inBufferLength)
bool CanReadImage() const
void SetFileName(const char *inFileName)
File const & GetFile() const
uint32_t DefineProperBufferLength() const
StreamImageReader.
Definition gdcmStreamImageWriter.h:43
void SetFile(const File &inFile)
void DefinePixelExtent(uint16_t inXMin, uint16_t inXMax, uint16_t inYMin, uint16_t inYMax, uint16_t inZMin=0, uint16_t inZMax=1)
uint32_t DefineProperBufferLength()
void SetStream(std::ostream &inStream)
bool Write(void *inWriteBuffer, const std::size_t &inBufferLength)
virtual bool WriteImageInformation()
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
@ ExplicitVRLittleEndian
Definition gdcmTransferSyntax.h:64
Class for generating unique UID.
Definition gdcmUIDGenerator.h:28
@ UI
Definition gdcmVR.h:87
@ CS
Definition gdcmVR.h:63
Writer ala DOM (Document Object Model)
Definition gdcmWriter.h:49
File & GetFile()
Definition gdcmWriter.h:67