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

10 vues (au cours des 30 derniers jours)
angelo covarrubias
angelo covarrubias le 16 Nov 2019
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

Réponses (1)

Jayanti
Jayanti le 1 Avr 2025
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!

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by