# Sir i am getting error :function isgray has been removed. Please suggest me which version of matlab i should use.

조회 수: 13(최근 30일)
amol 2014년 9월 26일
답변: DGM 2021년 10월 10일
Error description Error using isgray (line 7) Function ISGRAY has been removed.
Error in fpr (line 50) if (any(namefile~=0) && (~isgray(img)))

댓글을 달려면 로그인하십시오.

### 답변(3개)

Youssef Khmou 2014년 9월 26일
I think this function test an image of it is gray scale image, try to use an alternative way, using always logical answer, The grayscale image is 2D while others are higher, so replace the function with :
NN=length(size(image));
C=NN<=2;
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Image Analyst 2014년 9월 26일
You can check if it's a 2D gray scale image or a 3D color image by looking at either of these ways:
numDims = ndims(yourImage);
numDims = 2 for gray and 3 for RGB.
Or
[rows, colors, numberOfColorChannels] = size(yourImage);
numberOfColorChannels = 1 for gray, and 3 for RGB.
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
Steven Lord 2021년 10월 10일
FYI Steve Eddins discussed some of the ambiguity issues Walter Roberson described in a blog post from 2007.

댓글을 달려면 로그인하십시오.

DGM 2021년 10월 10일
As Steven notes, there are potential ambiguities with trying to do this. In my opnion, isgray() and isind() make some questionable assumptions. In order to meaningfully use isgray() you need to be aware of what it considers to be "gray". By the same token, if you adopt any other method, you need to accept the assumptions it implies.
I added ismono() to MIMT years ago because I disagreed with the assumptions made by isgray(). From the synopsis for ismono:
% ISMONO(INPICT,{TOL})
% Returns a logical value, true when INPICT is an I/IA logical or
% numeric array, or when INPICT is an RGB/RGBA image and all three color
% channels are identical to within a given tolerance. 4-D arrays of
% mono images return true only if all frames are mono images.
%
% IP Toolbox functions ISGRAY() and ISIND() provide similar functionality
% but will return false for any multi-channel or multi-frame array.
%
% ISMONO() does not discriminate between grey or indexed images
% or assume value ranges by class. ISMONO() will return true for a single-channel
% uint8 grey image (0-255) temporarily cast as double, whereas ISGRAY()/ISIND()
% will assume that it is an indexed image.
%
% INPICT is a 1, 2, 3, or 4 channel image array of any logical or numeric class.
% TOL is the tolerance used for checking RGB/RGBA images. (default 1E-12)
% This is the maximum allowable mean pixel difference.
% Using an excessively tight tolerance will tend to cause false negatives
% due to rounding error in desaturated images.
Speaking of assumed conventions, ismono() might work great -- so long as you don't expect that a multiframe image should be stacked on dim3 instead of dim4.
MIMT is available on the File Exchange.
...

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by