imwrite、saves、printf保存图片方法及区别:
https://blog.csdn.net/qq1987924/article/details/45496133
https://blog.csdn.net/holybin/article/details/39502077
画框:
使用imwrite保存可以保证图片大小不变,但是使用plot画框,因为没有改变图像原始像素值,因此imwrite后不能将框保存下来。
这是画框的方法是:改变图像的像素值:img(xmin:xmax, ymin:ymin+2, 1)= rand_color(1); %1为RGB之一,需要1,2,3都赋值,这里只画了一条横线,粗度为2像素
加文字:
close all
clc
I=imread('cameraman.tif');
ti=vision.TextInserter('Test', 'Location', [30 30],'FontSize', 12,'color', rand_color(1,:)); %颜色为rand随机生成的 rand_color = rand(1500,3);
img=step(ti,I);
figure
subplot(121),imshow(I),title('原始图像')
subplot(122),imshow(J),title('处理后图像,此图像可imwrite')
imwrite(img,[save_path,'\',img_list(t).name]);