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

조회 수: 1 (최근 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개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by