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

2 Ansichten (letzte 30 Tage)
angelo covarrubias
angelo covarrubias am 16 Nov. 2019
Beantwortet: Jayanti am 1 Apr. 2025
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

Antworten (1)

Jayanti
Jayanti am 1 Apr. 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!

Kategorien

Mehr zu Geometric Transformation and Image Registration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by