How to write a 16 bit image with a drawing rectangle in a folder

1 vue (au cours des 30 derniers jours)
I am working with a 16 bit DICOM Image whose size is 512*512. I want to draw a rectangle at 250,375 positions with length and width 50,50 respectively. I am capable to draw rectangle on that particular position. But, I am incapable to save the image with the rectangle. Is it possible to write the image with rectangle.
I=dicomread('F:\img1.dcm'); figure,imshow(X, []); hold on; title('16 bit image.', 'FontSize', 10); rectangle('Position', [250,375,100,100],... 'EdgeColor','r', 'LineWidth', 3); imwrite(X,'C:\Users\Jhilam\Desktop\code\myfile.png','WriteMode','append');

Réponse acceptée

Swarnava Pramanik
Swarnava Pramanik le 22 Juin 2018
Hi Jhilam,
As per your question you can save the image with the rectangle drawn at a specific coordinate using the “saveas” command. Here is a small code snippet to do that:
info = dicominfo('CT-MONO2-16-ankle.dcm');
Y = dicomread(info);
a = figure();
imshow(Y,[]);
hold on;
title('16 bit image.', 'FontSize', 10);
rectangle('Position', [250,375,100,100], 'EdgeColor','r', 'LineWidth', 3);
saveas(a,'dcmFile2.png')
Thanks,
Swarnava Pramanik

Plus de réponses (0)

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!

Translated by