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

3 次查看(过去 30 天)
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');

采纳的回答

Swarnava Pramanik
Swarnava Pramanik 2018-6-22
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

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by