How to change the pixel value and save it in DICOM format
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear Expert,
I have one data set as attached.
Now the pixel value in blob is 0.182868, then the rest is 0.
Anyone know how make it in the blop pixel is 0, the others is 1. Then save it in DICOM format.
clc
clear all
close all
sz = [128 128 128];
fname = 'pointho16610g.ict';
fid = fopen(fname);
data = fread(fid,'*float'); % assuming uint
fclose(fid);
data = reshape(data,sz);
imshow3D(data)

0 commentaires
Réponses (1)
Altaïr
le 27 Mar 2025
To observe the actual value at the (65,65,65) location, the following command can be used, which shows that the value truncates at the 25th decimal place. If the approximated value of 0.182868 is used to create the mask, a tolerance will need to be set:
>> fprintf('%.50f\n', imageData(65,65,65));
This outputs:
0.18286815285682678222656250000000000000000000000000
A logical operator can be employed to create the required mask by comparing the image with the value at (65,65,65). Here's the corresponding script:
% Load your image data
clc
clear all
close all
sz = [128 128 128];
fname = 'pointho16610g.ict';
fid = fopen(fname);
imageData = fread(fid,'*float'); % assuming uint
fclose(fid);
imageData = reshape(imageData,sz);
% Create the output image
blobValue = imageData(65,65,65); % approx 0.1828682
binaryMask = imageData ~= blobValue;
The dicomwrite function can be utilized to save the binary image. Ensure that the image size passed to the function is a m-by-n, m-by-n-by-3, or a 4-D array:
% Save the 65th frame as a DICOM file
dicomwrite(outputImage(:,:,65), 'outputImage.dcm');
For further details, please refer to the documentation page:
0 commentaires
Voir également
Catégories
En savoir plus sur DICOM Format dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!