How to save a plotted pattern onto an image
6 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
KSSV
on 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 Comments
student of PU
on 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
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
