Clear Filters
Clear Filters

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

1 view (last 30 days)
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');

Accepted Answer

Swarnava Pramanik
Swarnava Pramanik on 22 Jun 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

More Answers (0)

Categories

Find more on Image Processing Toolbox 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!