Can you update ROIs through interactions on the image after they are first created using dimensions?

3 views (last 30 days)
I have written code to automatically detect nuclei on one image, then draw ROIs around these on another based on the center and major/minor axes of these detected using regionprops. They nuclei ROIs are often very close to being the right size and in the right position but I would like the ability to manipulate them before creating masks and measuring the intensity in each ROI.
Here is my current code to create these ROIs:
figure; imshow(displayworm)
hold on;
for i=1:numberOfNuclei
NucRois(i) = drawellipse('InteractionsAllowed', 'all', 'Center', [allCentroids(i,1),allCentroids(i,2)],'SemiAxes',[allMajAxis(i)/2,allMinAxis(i)/2], 'RotationAngle', allOrient(i), 'Label', string(i), 'LabelAlpha', 0, 'LabelTextColor', 'y');
end
hold off;
I tried adding a 'pause' command after each nuclei was drawn to adjust the ROIs on the image (clicking and dragging them to change size and position). Here is what that looked like:
figure; imshow(displayworm)
hold on;
for i=1:numberOfNuclei
NucRois(i) = drawellipse('InteractionsAllowed', 'all', 'Center', [allCentroids(i,1),allCentroids(i,2)],'SemiAxes',[allMajAxis(i)/2,allMinAxis(i)/2], 'RotationAngle', allOrient(i), 'Label', string(i), 'LabelAlpha', 0, 'LabelTextColor', 'y');
pause;
end
hold off;
However, this did not actually change the ROIs that were stored in the variable and later used to create masks. Is there a way to plot an ROI using given positional information and then still modify it in the image?
  1 Comment
Image Analyst
Image Analyst on 10 Feb 2024
I do not understand this: "I have written code to automatically detect nuclei on one image, then draw ROIs around these on another based on the center and major/minor axes of these detected using regionprops." On another what? Image? Nuclei? What are the "detected"? The automatically detected nuclei or the hand traced regions or something else? Please use some annotated screenshots to explain your work process?
To save ROIs you can either keep them in a variable in your program, OR you can write the variable to a .mat file on disk.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 10 Feb 2024
Edited: Matt J on 10 Feb 2024
The version of your code that uses pause() works fine for me. However, I think it would be more convenient to use wait(). With wait(), you don't need to use the keyboard. You just double-click on the ROI to finalize its position.
for i=1:numberOfNuclei
h = drawellipse('InteractionsAllowed', 'all', ...
'Center', [allCentroids(i,1),allCentroids(i,2)], ...
'SemiAxes',[allMajAxis(i)/2,allMinAxis(i)/2], ...
'RotationAngle', allOrient(i), ...
'Label', string(i), 'LabelAlpha', 0, 'LabelTextColor', 'y');
wait(h); %double-click to finalize
NucRois(i)=h;
end

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!