Unable to change PixelData correctly #1858
-
Hello. I'm trying open dcm file, change PixelData (load it from raw file) and then save the result. DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("input.dcm");
resultDset = fileformat.getDataset();
int height = 2800;
int width = 2304;
int size = height*width;
uint16_t* data = new uint16_t[size];
FILE* pixelStream = fopen("test.bin","rb");
if (!pixelStream){
printf("Coudn't open binary file\n");
return;
}
fread(data,sizeof(uint16_t),size,pixelStream);
fclose(pixelStream);
resultDset->putAndInsertUint16Array(DCM_PixelData, data, size); This is my Python script: import numpy
from pydicom import dcmread
ds = dcmread("input.dcm")
pixels=numpy.fromfile('test.bin',dtype=numpy.uint16)
ncols=2304
pixels.shape=(pixels.size//ncols, ncols)
ds.PixelData=pixels.tobytes()
ds.save_as("output.dcm") The output.dcm file was written incorrectly: i see black window instead of image. |
Beta Was this translation helpful? Give feedback.
Answered by
mrbean-bremen
Aug 3, 2023
Replies: 2 comments
-
Your file in input.zip is not a DICOM file, it's a TIFF file with a DICOM extension. May be you have provided the wrong file? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nagayev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your file in input.zip is not a DICOM file, it's a TIFF file with a DICOM extension. May be you have provided the wrong file?