Matlab中如何只把figure中的图像区域保存为图片文件
Matlab中如何只把figure中的图像区域保存为图片文件[ 本帖最后由 eight 于 2008-5-14 15:29 编辑 ] 好像除了拷屏,
其它的方法都只是把图像区域保存的吧
回复 楼主 的帖子
save as?回复 3楼 的帖子
那就多了edit-->copy figure
save as
export setup-->export alt+printscrean
这个是只拷当前活动窗口 呵呵
用qq截图
:lol %%%%矩形区域选取%%%%%
hf = figure(1);
A = imread('board.tif');
A = rgb2gray(A); %-此句注释后下面的处理就相当于对真彩色图像进行
imshow(A)
rect = getrect(hf);
w = round(rect(3));
h = round(rect(4));
if w >= 1 & h >= 1
r = ;
rectangle('Position',, 'edgecolor','red');
figure(2);
bw = roipoly(A,r(1,:),r(2,:));
AA = reshape(A, [(size(A,1)*size(A,2)), size(A,3)]);
BB = AA(bw, :);
B = reshape(BB, );
imshow(B);
end
%%%%任意形状区域选取%%%%%
clear all
A = imread('board.tif');
A = rgb2gray(A); %-此句注释后下面的处理就相当于对真彩色图像进行
figure(1)
imshow(A);
% = ginput;
button = 1;
n = 0;
a = [];
b = [];
hold on;
while button == 1 % 输入数据点,以右键作结
= ginput(1);
n = n + 1;
if n > 1
plot(, , '-rs','LineWidth',1,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10);
else
plot(xi, yi, 's','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10);
end
a(n,1) = xi;
b(n,1) = yi;
end
plot(, , '-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10);
hold off;
if length(a) >= 3
va = round(a);
vb = round(b);
x = 1:size(A,1);
y = 1:size(A,2);
= meshgrid(y,x);
in = inpolygon(Y(:),X(:),va,vb);
AA = reshape(A, );
BB = repmat(uint8(255),size(AA));
BB(in,:) = AA(in,:);
B = reshape(BB, );
figure(2)
imshow(B);
end
选自eight总结贴。
选出感兴趣的区域后,把figure文件保存为需要的格式即可。 以下命令仅取图像区域
f=getframe(gca);
imwrite(f.cdata,'f:\test2.png')
页:
[1]