Problem converting and displaying Dicom(ultrasonics) image for Matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I have a project to read a DICOM file and determine if it is a DICOM file or not. Then read the content of the file and convert it to Matrix and then display it as an image. But unfortunately the picture always appears like this for me
But when I view the image in another program, it appears in its true form
elseif strcmp(Group,'7FE0')
if strcmp(Element,'0010')
if dicom_data{7,5}==16
dcmImage = uint16(fread(fID,[dicom_data{5,5} dicom_data{6,5}],'uint16')');
dicom_data{10,5} = dcmImage;
else
dcmImage = uint16(fread(fID,[dicom_data{5,5} dicom_data{6,5}],'uint8')');
dicom_data{10,5} = dcmImage;
end
else
fseek(fID,ValueLength,0);
end
else
if(ftell(fID)==DateiEnde)
break
end
fseek(fID,ValueLength,0);
end
end
imshow(dicom_data,[0 2^dicom_data{9,5}])
This is the data it reads from the DICOM file
ans =
10×5 cell array
{'TransferSyntax' } {'2' } {'10' } {'UI'} {'1.2.840.10008.1…'}
{'PatientName' } {'10' } {'10' } {'PN'} {'no patient' }
{'SamplesPerPixel'} {'28' } {'2' } {'US'} {[ 3]}
{'NumberOfFrames' } {'28' } {'8' } {'IS'} { 2×1 char }
{'Rows' } {'28' } {'10' } {'US'} {[ 512]}
{'Cols' } {'28' } {'11' } {'US'} {[ 512]}
{'BitsAllocated' } {'28' } {'100'} {'US'} {[ 8]}
{'BitsStored' } {'28' } {'101'} {'US'} {[ 8]}
{'HighBit' } {'28' } {'102'} {'US'} {[ 7]}
{'PixelData' } {'7FE0'} {'10' } {'OB'} {512×512 uint16 }
7 件のコメント
回答 (1 件)
aditi bagora
2023 年 10 月 10 日
Hello Khaled,
I understand you want to read a DICOM (ultrasonics) file and extract the values from its metadata. It seems that you are currently using the "fread()" and "fseek()" functions to read the binary file. However, you are encountering issues when reading the pixel data, which could be due to a mismatch in reading the binary data in a particular format or inconsistent data in the file.
To overcome these issues, you can manually try reading the binary file using "fread()" and "fseek()", you can try using the "dicomread()" and "dicominfo()" functions. These functions are specifically designed to read pixel data and metadata from DICOM files, ensuring compatibility and accurate extraction.
To read the pixel data and dicom data, you can refer to the following example code:
pixel_data = dicomread(filename); % read pixel data
imshow(pixel_data);
dicom_data = dicominfo(filename); % To read the DICOM metadata.
Please refer to the following links for more information:
- Read metadata from DICOM message - MATLAB dicominfo - MathWorks India
- Read DICOM image - MATLAB dicomread - MathWorks India
- Accessing data in DICOM files - MATLAB & Simulink (mathworks.com)
- How to check if file is a dicom file or not
Hope this helps!
Regards,
Aditi
1 件のコメント
Walter Roberson
2023 年 10 月 10 日
The purpose of the project was to learn how to use low-level facilities to work with files.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!