Matlab 画平滑轮廓 print 高质量 figure

来源:互联网 发布:做淘宝加盟要多少钱 编辑:程序博客网 时间:2024/06/08 07:13

Matlab 画平滑轮廓 print 高质量 figure

在matlab中,想将分割的结果以轮廓的形式显示到灰度图上,要提取、绘制平滑轮廓。 自己提取轮廓、绘制,不方便,效果差。 matlab提供了函数接口,且绘制结果用print函数来保存成分辨率可控、无白边的的高质量图像。

代码如下:

代码实现的功能是: 将二值化分割图像 seg.png 中的轮廓绘制到 图像 12.bmp上,以实现分割效果的显示。

close all; clear all;clc;SaveSize = [768 576];Res = 100;ImgSave_Name = 'F:\1.png';A = imread('12.bmp');B = imread('Seg.png');C = rgb2gray(A);h = figure(1); imshow(C,'border','tight','initialmagnification','fit'), hold onset(gcf,'PaperPositionMode', 'manual');set(gcf,'PaperUnits','inches');set(gcf,'PaperPosition', [0 0 SaveSize(1)/Res SaveSize(2)/Res]);% ContourB = B(:,:,1)==255;contour(B, 1, 'linecolor','g');print(gcf, ['-r',num2str(Res)], '-dpng',ImgSave_Name);close(h);



0 0