Why I am not able to view the comments whichever I embedded into Dicom image as metadata?
Show older comments
% Following is my code..Here I am reading the Dicom image. And Wherever i
% want toinsert the comment I am giving the comments by locating the
% points.Then i am displaying watermarked and original image.But later if i
% view the metadata at that time am not able view that comment.Please help
% me me in this code
% Read the DICOM image
dicomImage = dicomread('ID_0000_AGE_0060_CONTRAST_1_CT.dcm');
% Create a figure to display both images side by side
figure;
% Display the original DICOM image on the left
subplot(1, 2, 1);
imshow(dicomImage, []);
title('Original DICOM Image');
% Let the user locate the point
uiwait(msgbox('Click on the image to locate the point.'));
[x, y] = ginput(1);
% Get user input for the text message
prompt = 'Enter the comment text: ';
dlgtitle = 'Input';
dims = [1 50];
definput = {''}; % Default input is an empty string
textToInsert = inputdlg(prompt, dlgtitle, dims, definput);
% Create a DICOM metadata structure
dicomInfo = dicominfo('ID_0000_AGE_0060_CONTRAST_1_CT.dcm');
% Add comments to the metadata (you can use any appropriate DICOM field for comments)
dicomInfo.ClinicalTrialSeriesDescription = textToInsert;
% Write the DICOM image with embedded comments to a new DICOM file
dicomwrite(dicomImage, 'Watermarked_DICOM.dcm', dicomInfo);
% Read the watermarked DICOM image
watermarkedImage = dicomread('Watermarked_DICOM.dcm');
% Display the watermarked DICOM image on the right
subplot(1, 2, 2);
imshow(watermarkedImage, []);
title('Watermarked DICOM Image with Comments');
% Adjust the positions of the subplots for better visualization
%set(gca, 'Position', [0.5, 0.1, 0.4, 0.7]);
Accepted Answer
More Answers (0)
Categories
Find more on Read and Write Image Data from Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!