imcontour.m
来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 91 行
M
91 行
function [c,h] = imcontour(x,y,a,n)
%IMCONTOUR Create contour plot of image data.
% IMCONTOUR(I,N) draws a contour plot of the intensity image I,
% automatically setting up the axes so their orientation and
% aspect ratio match the image. N is the number of equally
% spaced contour levels in the plot; if you omit the argument,
% the number of levels and the values of the levels are chosen
% automatically.
%
% IMCONTOUR(I,V) draws a contour plot of I with contour lines
% at the data values specified in vector V. The number of
% contour levels is equal to length(V).
%
% IMCONTOUR(X,Y,...) uses the vectors X and Y to specify the x-
% and y-axis limits.
%
% IMCONTOUR(...,LINESPEC) draws the contours using the line
% type and color specified by LINESPEC. Marker symbols are
% ignored.
%
% [C,H] = IMCONTOUR(...) returns the contour matrix C and a
% vector of handles to the objects in the plot. (The objects
% are actually patches, and the lines are the edges of the
% patches.) You can use the CLABEL function with the contour
% matrix C to add contour labels to the plot.
%
% Class Support
% -------------
% The input image can be of class uint8 or double.
%
% Example
% -------
% I = imread('ic.tif');
% imcontour(I,3)
%
% See also CLABEL, CONTOUR.
% Clay M. Thompson 10-6-92
% Copyright 1993-1998 The MathWorks, Inc. All Rights Reserved.
% $Revision: 5.6 $ $Date: 1997/11/24 15:35:20 $
if nargin==1, % imcontour(a)
a = x;
x = 1:size(a,2); y = 1:size(a,1);
elseif nargin==2, % imcontour(a,n) or imcontour(a,v)
a = x;
n = y;
x = 1:size(a,2); y = 1:size(a,1);
end
% Make sure x,y are vectors.
if all(size(x)==size(a)), x = x(1,:); end
if all(size(y)==size(a)), y = y(:,1); end
% If x and y are two-element vectors, make them be the
% same size as a.
x = x(:);
y = y(:);
if (length(x) ~= size(a,2))
if (length(x) ~= 2)
error('Invalid size of X');
end
x = linspace(x(1), x(end), size(a,2));
end
if (length(y) ~= size(a,1))
if (length(y) ~= 2)
error('Invalid size of Y');
end
y = linspace(y(1), y(end), size(a,1));
end
if nargout==0,
if nargin==1 | nargin==3,
contour(x,y,a)
else
contour(x,y,a,n)
end
else
if nargin==1 | nargin==3,
[c,h] = contour(x,y,a);
else
[c,h] = contour(x,y,a,n);
end
end
if ~ishold,
axis ij
axis image
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?