1) If the file is compressed (lossless jpeg) and I attempt to scale it down it outputs the same file (no scaling was done).
2) Doing the same as above but if the output file is the same as the input file, it seems to create an invalid image. The file seems to be OK, but ezDicom can't process the pixeldata properly ("Unable to read this file - is this really a JPEG image?")
3) If the file is not compressed, the image gets scaled but the colors are wrong.
Heres the code I use:
Code: Select all
DcmFileFormat fileformat;
OFCondition error = fileformat.loadFile( input );
... // deal with bad input
DcmDataset *dataset = fileformat.getDataset();
DicomImage* di = new DicomImage( &fileformat, dataset->getOriginalXfer() );
DicomImage* rescaledDi = di->createScaledImage( oColumns, oRows, 1 );
bool b = rescaledDi->writeImageToDataset ( *dataset, 1 );
fileformat.saveFile( output );
delete di;
delete rescaledDi;
I get similar results with dcmscale.exe:
Using "dcmscale.exe +Sxv 500 input out" I get an error if the input file is compressed ("ERROR: cannot change to unencapsulated representation for pixel data !").
If it is not compressed, the image is scaled down, but the colors are wrong.
You can get the image I'm using here (3MB):
http://rapidshare.com/files/2545784/scaling_trouble.rar (JPEG Lossless)
What am I doing wrong?