【文件属性】:
文件名称:isrgb.m,matlab
文件大小:1KB
文件格式:M
更新时间:2017-04-16 11:04:35
isrgb.m matlab rgb
isrgb.m matlab rgb
function y = isrgb(x)
%ISRGB Return true for RGB image.
% FLAG = ISRGB(A) returns 1 if A is an RGB truecolor image and
% 0 otherwise.
%
% ISRGB uses these criteria to determine if A is an RGB image:
%
% - If A is of class double, all values must be in the range
% [0,1], and A must be M-by-N-by-3.
%
% - If A is of class uint8 or uint16, A must be M-by-N-by-3.
%
% Note that a four-dimensional array that contains multiple RGB
% images returns 0, not 1.
%
% Class Support
% -------------
% A can be of class uint8, uint16, or double. If A is of
% class logical it is considered not to be RGB.
%
% See also ISBW, ISGRAY, ISIND.
% Copyright 1993-2003 The MathWorks, Inc.
% $Revision: 1.15.4.2 $ $Date: 2003/08/23 05:52:55 $
wid = sprintf('Images:%s:obsoleteFunction',mfilename);
str1= sprintf('%s is obsolete and may be removed in the future.',mfilename);
str2 = 'See product release notes for more information.';
warning(wid,'%s\n%s',str1,str2);
y = size(x,3)==3;
if y
if isa(x, 'logical')
y = false;
elseif isa(x, 'double')
% At first just test a small chunk to get a possible quick negative
m = size(x,1);
n = size(x,2);
chunk = x(1:min(m,10),1:min(n,10),:);
y = (min(chunk(:))>=0 && max(chunk(:))<=1);
% If the chunk is an RGB image, test the whole image
if y
y = (min(x(:))>=0 && max(x(:))<=1);
end
end
end
网友评论
- 可以用,要把图片赋一个变量,然后调用这个函数,是rgb图像返回1,不是返回0,会出现warning,不影响 H=imread('car_1.jpg');u=isrgb(H); u = logical 1
- 下载一下看能不能用
- 还不错,下载了可以用啊
- 好用,经常碰到这问题,烦死了
- 还不错,下载了可以用啊
- 这个函数isrgb以前是matlab自带的现在被matlab删除了,其实还是蛮有用的,支持一下
- 很好,有用,解决了我的问题