Get an image from a fgure window

D
divya r · Feb 8, 2023 · 2K views
Question
I have an image which has a lot of circles. So I have used imfindcirles and viscircles to find and visualize the circles in a figure window. Now I want to get the image as it is and store it in a variable in the program.   I tried using getimage, but it gets only the original image, without the circles marked in it.
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 23, 2026

Did you try to get cdata?

 

theFrame = get(gca, 'CData');

If that doesn't work, use export_fig.

I am getting an error when I am using cdata. I have attached the code below:

data = imread('coins.webp');  
figure();  
imshow(data);  
[centers radii] = imfindcircles(data,[3 10], 'Sensitivity', 0.92,'Edge', 0.03);  
theFrame = get(gca, 'CData');  
figure();  
imshow(theFrame);

The error is :

Error using hg.axes/get
The name 'CData' is not an accessible property for an instance of class 'axes'.
 
I tried using copyfig from export_fig directory, but it didnt work either.
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!