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

21 views (last 30 days)
amol on 26 Sep 2014
Answered: DGM on 10 Oct 2021
Error description Error using isgray (line 7) Function ISGRAY has been removed.
Error in fpr (line 50) if (any(namefile~=0) && (~isgray(img)))

Youssef Khmou on 26 Sep 2014
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;

Image Analyst on 26 Sep 2014
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.
Steven Lord on 10 Oct 2021
FYI Steve Eddins discussed some of the ambiguity issues Walter Roberson described in a blog post from 2007.

DGM on 10 Oct 2021
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.
...