How to save a plotted pattern onto an image

7 Ansichten (letzte 30 Tage)
Beatrice Pazzucconi
Beatrice Pazzucconi am 1 Nov. 2017
Kommentiert: student of PU am 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

Akzeptierte Antwort

KSSV
KSSV am 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 Kommentare
KSSV
KSSV am 6 Nov. 2017
Okay..hope you got your problem solved....
student of PU
student of PU am 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images 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