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

10 ビュー (過去 30 日間)
angelo covarrubias
angelo covarrubias 2019 年 11 月 16 日
回答済み: Jayanti 2025 年 4 月 1 日
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 Center および File ExchangeGeometric 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