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

6 views (last 30 days)
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 :
NN=length(size(image));
C=NN<=2;

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.
Or
[rows, colors, numberOfColorChannels] = size(yourImage);
numberOfColorChannels = 1 for gray, and 3 for RGB.
  3 Comments
Walter Roberson
Walter Roberson on 10 Oct 2021
There are different conventions for black and white images:
islogical(yourImage) || ...
(isfloat(yourImage) && all(ismember(yourImage(:), [0 1]))) || ...
(isinteger(yourImage) && all(ismember(yourImage(:), [intmin(class(yourImage)), intmax(class(yourImage))])))
but sometimes an image is considered to be black and white if it is either all one gray intensity or else exactly two gray intensities -- for example, a double precision image image that had values 0. and 255. might be considered black and white (such an image would probably have been produced by someone using double(yourImage) instead of im2double(yourImage)) )

Sign in to comment.


DGM
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.
...

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!