Problem converting and displaying Dicom(ultrasonics) image for Matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
aditi bagora
am 10 Okt. 2023
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 Kommentar
Walter Roberson
am 10 Okt. 2023
The purpose of the project was to learn how to use low-level facilities to work with files.
Siehe auch
Kategorien
Mehr zu DICOM Format finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!