histroi.m
来自「冈萨雷斯的经典教材数字图像处理的matlab版源代码」· M 代码 · 共 26 行
M
26 行
function [p, npix] = histroi(f, c, r)
%HISTROI Computes the histogram of an ROI in an image.
% [P, NPIX] = HISTROI(F, C, R) computes the histogram, P, of a
% polygonal region of interest (ROI) in image F. The polygonal
% region is defined by the column and row coordinates of its
% vertices, which are specified (sequentially) in vectors C and R,
% respectively. All pixels of F must be >= 0. Parameter NPIX is the
% number of pixels in the polygonal region.
% Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
% Digital Image Processing Using MATLAB, Prentice-Hall, 2004
% $Revision: 1.5 $ $Date: 2003/09/05 16:14:35 $
% Generate the binary mask image.
B = roipoly(f, c, r);
% Compute the histogram of the pixels in the ROI.
p = imhist(f(B));
% Obtain the number of pixels in the ROI if requested in the output.
if nargout > 1
npix = sum(B(:));
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?