How to interactively display the size of ROI created by imellipse?

4 Ansichten (letzte 30 Tage)
YZ
YZ am 2 Mär. 2017
Bearbeitet: Matt J am 2 Mär. 2017
I want to draw a ROI on one image with imellipse and display the size of ROI, so that I can adjust the size of ROI to the desired size. The following is my code:
figure(1)
h_im = imshow(myimage);
roi_small = imellipse;
BW_small_temp = sum(sum(createMask(roi_small, h_im)));
BW_small_temp_area = BW_small_temp * info_MTL.(current_name).PixelSpacing(1)*info_MTL.(current_name).PixelSpacing(2);
txt1 = [num2str(BW_small_temp_area) ' mm^2'];
text(256,256,txt1)
wait_small = wait(roi_small);
pos_small = getPosition(roi_small);
This code can only display the ROI size at the first attempt. By adjusting the size of ROI, the text in the figure won't change. Please see the picture:
Is there a way to display the text of ROI size interactively, such that when adjusting the ROI size, the text of ROI size also changes? Many thanks!

Antworten (1)

Matt J
Matt J am 2 Mär. 2017
Bearbeitet: Matt J am 2 Mär. 2017
The function you use to display the area can be attached to roi_small using its addNewPositionCallback() method. This function will then be called every time the ROI is moved or re-sized.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by