How to save a plotted pattern onto an image

6 vues (au cours des 30 derniers jours)
Beatrice Pazzucconi
Beatrice Pazzucconi le 1 Nov 2017
Commenté : student of PU le 3 Sep 2020
Hi,
I am trying to save an image with a circle drawn on it. I tried with both imwrite and print, but then when I open the file again, the plotted circle is gone.
Image = imread('Eye_00001.jpg');
figure('visible', 'off')
imshow(Image)
% plot circle (CRx and CRy are center coordinates, CRr is radius)
hold on
th = 0:pi/50:2*pi;
xunit = CRr * cos(th) + CRx;
yunit = CRr * sin(th) + CRy;
plot(xunit, yunit, 'r');
% plot the circle center
scatter(CRx, CRy, 20, 'r+');
hold off
% save the image:
save_file_name = strcat(working_directory_name, 'Eye_res_00001.jpg');
imwrite(Image, res_filename)
close(figure)
The version with print changes in the lines:
save_file_name = strcat(working_directory_name, 'Eye_res_00001');
print(res_filename, '-djpeg')
Is there something I'm getting wrong?
Thanks everybody in advance

Réponse acceptée

KSSV
KSSV le 2 Nov 2017
Image = imread('Eye_00001.jpg');
figure('visible', 'off')
imshow(Image)
% plot circle (CRx and CRy are center coordinates, CRr is radius)
hold on
th = 0:pi/50:2*pi;
xunit = CRr * cos(th) + CRx;
yunit = CRr * sin(th) + CRy;
plot(xunit, yunit, 'r');
% plot the circle center
scatter(CRx, CRy, 20, 'r+');
hold off
F = getframe ;
% save the image:
save_file_name = strcat(working_directory_name, 'Eye_res_00001.jpg');
imwrite(F.cdata, res_filename)
close(figure)
  8 commentaires
KSSV
KSSV le 6 Nov 2017
Okay..hope you got your problem solved....
student of PU
student of PU le 3 Sep 2020
i am facing the same problem. i tried this code but still not able to save the image with circle over it. kindly help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Images 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