how to save the image to which viscircles (centers, radii) apply?

4 次查看(过去 30 天)
I'm new to Matlab and I have a problem. The binarized image is saved and the one I want to save is the image that viscircles applies (centers, radii).
for i=1:totalimag
imag{i}=importdata(fullfile(ruta,imag{i}),' ');
%binarizar img
imgbn{i}=rgb2gray(imag{i});
[centers,radii] = imfindcircles(imgbn{i},[5 30],'ObjectPolarity','Dark',...
'Sensitivity',0.92);
imshow(imgbn{i})
%se dibujan círculos en imgbn
h{i} = viscircles(centers,radii);
eval(sprintf(' var%d = centers,radii', i))
carpeta='C:\Users\angel\Desktop\programas\Matlabt';
namefile= [carpeta, '\imacept', num2str(i), '.jpg'];
imwrite(imgbn{i},namefile)
end

回答(1 个)

Jayanti
Jayanti 2025-4-1
Hi Angelo,
To save the images with the circles drawn in it you can capture the figure with the circles and save it.
Please refer to the below code:
hFig = figure;
imshow(imgbn{i});
hold on;
viscircles(centers, radii);
saveas(hFig, filename);
close(hFig);
The above code will display the image by creating a figure window. “saveas” is used to save the current figure with the circles drawn on it with the file “filename”. Specify the file name as a character vector or string that includes a file extension. If not, then “saveas” saves the figure to a FIG-file.
I am also attaching documentation link on “saveas” for your reference:
Hope this will be helpful!

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by