现在的位置: 首页 > 综合 > 正文

Matlab 画平滑轮廓 print 高质量 figure

2018年10月28日 ⁄ 综合 ⁄ 共 631字 ⁄ 字号 评论关闭

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 on
set(gcf,'PaperPositionMode', 'manual');
set(gcf,'PaperUnits','inches');
set(gcf,'PaperPosition', [0 0 SaveSize(1)/Res SaveSize(2)/Res]);
% Contour
B = B(:,:,1)==255;
contour(B, 1, 'linecolor','g');
print(gcf, ['-r',num2str(Res)], '-dpng',ImgSave_Name);
close(h);

抱歉!评论已关闭.