资源简介
本源代码来自于网站。代码能够在读入的图片中进行直线、折线的绘制,并能够控制端点标记。这个代码弥补了matlab在原图中绘制图形的缺陷。matlab plot函数绘制的线段,并没有改变读入图片的数据,直接保存图片的矩阵数据,不会保留绘制的直线。利用print、saveas 等函数保存厚的图片尺寸和以前大小不同,而且保存的图片存在空白边框问题。该代码完美解决了这一问题。
代码片段和文件信息
function I=bitmapplot(xyIbackgroundoptions)
% BITMAPPLOT Linear plot in bitmap.
%
% Iplot=bitmapplot(xyIbackgroundoptions)
%
% inputs
% x : a vector with x values
% y : a vector with y values with same length as x
% Ibackground: the bitmap used as background when a m x n x 3 matrix
% color plots are made when m x n a greyscale plot.
% options: struct with options such as color
%
% outputs
% Iplot: The bitmap containing the plotted lines
%
% note
% Colors are always [r(ed) g(reen) b(lue) a(pha)] with range 0..1.
% when Ibackground is grayscale the mean of rgb is used as grey value.
%
% options
% options.Color: The color of the line.
% options.FillColor: If this color is set the region between
% the x and y coordnates will be filled with this color.
% options.LineWidth: Thickness of the line in pixels 123..n
% options.Marker: The marker type: ‘o‘ ‘+‘ or ‘*‘.
% options.MarkerColor: The color of the markers used.
% options.MarkerSize: The size of the markers used
%
% example
% % Make empty bitmap
% I = zeros([320 256 3]);
%
% % Add a line
% x=rand(110)*50+50; y=linspace(151210);
% I=bitmapplot(xyI);
%
% % Add a thick red line
% x=rand(110)*50+100; y=linspace(125610);
% I=bitmapplot(xyIstruct(‘LineWidth‘5‘Color‘[1 0 0 1]));
%
% % Add a line with markers
% x=rand(110)*50+150; y=linspace(125610);
% I=bitmapplot(xyIstruct(‘Marker‘‘*‘‘MarkerColor‘[1 0 1 1]‘Color‘[1 1 0 1]));
%
% % Add a filled polygon
% x=[1 100 30 100]+200; y=[30 1 250 200];
% I=bitmapplot(xyIstruct(‘FillColor‘[0 1 0 0.5]‘Color‘[1 1 0 1]));
%
% % Add a filled polygon on top
% x=[30 80 70 120]+200; y=[30 1 250 200];
% I=bitmapplot(xyIstruct(‘FillColor‘[1 0 0 0.5]‘Color‘[1 0 0 1]));
%
% lines={‘Plot Test‘‘BitmapPlot version 1.2‘};
% % Plot text into background image
% I=bitmaptext(linesI[1 1]struct(‘Color‘[1 1 1 1]));
%
% % Show the bitmap
% figure imshow(I);
%
% Function is written by D.Kroon University of Twente (April 2009)
% Process inputs
defaultoptions=struct(‘Color‘[0 0 1 1]‘FillColor‘[]‘LineWidth‘1‘Grid‘[]‘MarkerColor‘[1 0 0 1]‘Marker‘[]‘MarkerSize‘6);
if(~exist(‘options‘‘var‘))
options=defaultoptions;
else
tags = fieldnames(defaultoptions);
for i=1:length(tags)
if(~isfield(optionstags{i})) options.(tags{i})=defaultoptions.(tags{i}); end
end
if(length(tags)~=length(fieldnames(options)))
warning(‘register_images:unknownoption‘‘unknown options found‘);
end
end
% The function works with double values (store class for ouput)
Classb=class(Ibackground);
Ibackground=im2double(Ibackground);
% x and y to row vectors
x=round(x(:))‘; y=round(y(:))‘;
% Make line marker an fill bitmap
I_line=zeros([size(Ibackground1) size(Ibackground2)]);
I_marker=zeros([size(Ibackground1) size(Ibac
相关资源
- 用MATLAB的GUIDE工具做有GUI界面的串口通
- Matlab绘制邻接矩阵
- install_supportsoftware_VGG19.exe
- 最小二乘匹配算法、matlab版
- 将matlab中数据输出保存为txt或dat格式
- PID 算法Matlab详解
- Matlab批量转换图片格式
- matlab实现PCM十三折现编码译码
- 经典开环子空间辨识
- EKFUKFmatlab程序比较
- camshift跟踪算法MATLAB源代码注释.txt
- 系统辨识部分算法matlab程序
- LBP算法的Matlab代码
- MATLAB随机拓扑生成源码
- 模糊k均值聚类算法matlab实现
- 色调,饱和度,亮度图,matlab
- 地统计学中的克里格插值法,Matlab编
- 利用MATLAB对图像进行灰度阈值分割,
- matlab计算GTD-UTD绕射源代码.zip
- IEEE30节点测试系统matlab M文件,包含各
- 说话人识别和确认系统Matlab).rar
- 力导向图force-direct算法MATLAB实现含数
- photoshop图层混合的matlab实现
- 3-SPR并联平台Matlab运动学正解及工作空
- 小生境遗传算法源程序4
- 《现代数字信号处理》何子述 第三章
- CNN深度学习识别字符matlab
- 车牌识别matlab代码
- 粒子群算法优化RBF神经网络
- QPSK的MATLAB仿真程序
评论
共有 条评论