void delta_decode(const char *inbuffer, size_t length, std::vector<unsigned short> &output)
{
std::vector<char> temp;
for(size_t i = 0; i < length; ++i)
{
if( inbuffer[i] == (char)0xa5 )
{
int repeat = (unsigned char)inbuffer[i+1] + 1;
char value = inbuffer[i+2];
while(repeat)
{
temp.push_back( value );
--repeat;
}
i+=2;
}
else
{
temp.push_back( inbuffer[i] );
}
}
unsigned short delta = 0;
for(size_t i = 0; i < temp.size(); ++i)
{
if( temp[i] == 0x5a )
{
unsigned char v1 = (unsigned char)temp[i+1];
unsigned char v2 = (unsigned char)temp[i+2];
unsigned short value = (unsigned short)(v2 * 256 + v1);
output.push_back( value );
delta = value;
i+=2;
}
else
{
unsigned short value = (unsigned short)(temp[i] + delta);
output.push_back( value );
delta = value;
}
}
if ( output.size() % 2 )
{
output.resize( output.size() - 1 );
}
std::cout << length << " -> " << output.size() * 2 << std::endl;
}
int main(int argc, char *argv [])
{
if( argc < 2 )
{
std::cerr << argv[0] << "input.dcm [output.dcm]" << std::endl;
std::cerr << "will default to 'outrle.dcm' unless output.dcm is specified."
<< std::endl;
return 1;
}
const char *filename = argv[1];
{
std::cerr << "Failed to read: " << filename << std::endl;
return 1;
}
if ( compressiontype.
IsEmpty() )
return 1;
std::string comprle = "PMSCT_RLE1";
std::string comprgb = "PMSCT_RGB1";
bool isrle = false;
bool isrgb = false;
if( strncmp( bv->
GetPointer(), comprle.c_str(), comprle.size() ) == 0 )
{
isrle = true;
}
if( strncmp( bv->
GetPointer(), comprgb.c_str(), comprgb.size() ) == 0 )
{
isrgb = true;
std::cerr << "See: pmsct_rgb1.cxx instead" << std::endl;
return 1;
}
if( !isrgb && !isrle ) return 1;
const gdcm::Tag tstandardpixeldata(0x7fe0, 0x0010);
else if(ds.
FindDataElement(tstandardpixeldata)) tpixeldata = tstandardpixeldata;
if ( compressionpixeldata.
IsEmpty() )
return 1;
{
}
else{
}
if( bv2l == at1l )
{
}
else
{
std::vector<unsigned short> buffer;
pixeldata.
SetByteValue( (
char*)buffer.data(), (uint32_t)(buffer.size() *
sizeof(
unsigned short )) );
}
{
}
else
{
}
{
}
{
}
std::string outfilename;
if (argc > 2)
outfilename = argv[2];
else
outfilename = "outrle.dcm";
{
std::cerr << "Failed to write" << std::endl;
return 1;
}
std::cout << "success !" << std::endl;
return 0;
}
Attribute class This class use template metaprograming tricks to let the user know when the template ...
Definition gdcmAttribute.h:86
ArrayType & GetValue(unsigned int idx=0)
Definition gdcmAttribute.h:154
void SetFromDataSet(DataSet const &ds)
Definition gdcmAttribute.h:229
Class to represent binary value (array of bytes)
Definition gdcmByteValue.h:35
const char * GetPointer() const
Definition gdcmByteValue.h:110
VL GetLength() const override
Definition gdcmByteValue.h:77
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
const ByteValue * GetByteValue() const
Definition gdcmDataElement.h:133
bool IsEmpty() const
Check if Data Element is empty.
Definition gdcmDataElement.h:106
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
const DataElement & GetDataElement(const Tag &t) const
Definition gdcmDataSet.h:188
void ReplaceEmpty(const DataElement &de)
Only replace a DICOM attribute when it is missing or empty.
Definition gdcmDataSet.h:161
bool FindDataElement(const PrivateTag &t) const
Look up if private tag 't' is present in the dataset:
SizeType Remove(const Tag &tag)
Completely remove a dataelement from the dataset.
Definition gdcmDataSet.h:172
void Replace(const DataElement &de)
Replace a dataelement with another one.
Definition gdcmDataSet.h:150
const DataSet & GetDataSet() const
Get Data Set.
Definition gdcmFile.h:57
const FileMetaInformation & GetHeader() const
Get File Meta Information.
Definition gdcmFile.h:48
Class to represent a Private DICOM Data Element (Attribute) Tag (Group, Element, Owner)
Definition gdcmPrivateTag.h:39
Reader ala DOM (Document Object Model)
Definition gdcmReader.h:54
const File & GetFile() const
Set/Get File.
Definition gdcmReader.h:72
virtual bool Read()
Main function to read a file.
void SetFileName(const char *filename_native)
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
@ ExplicitVRLittleEndian
Definition gdcmTransferSyntax.h:64
Value Length.
Definition gdcmVL.h:30
@ OW
Definition gdcmVR.h:77
Writer ala DOM (Document Object Model)
Definition gdcmWriter.h:49
File & GetFile()
Definition gdcmWriter.h:67
virtual bool Write()
Main function to tell the writer to write.
void SetFile(const File &f)
Set/Get the DICOM file (DataSet + Header)
Definition gdcmWriter.h:66
void SetFileName(const char *filename_native)
Set the filename of DICOM file to write: