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

13 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)))

Answers (3)

Youssef  Khmou
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 :

Image Analyst
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.
[rows, colors, numberOfColorChannels] = size(yourImage);
numberOfColorChannels = 1 for gray, and 3 for RGB.

Sign in to comment.

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:
% 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!