Error using rgb2gray>parse_inputs , MAP must be a m x 3 array. Use im2gray for RGB and grayscale images.

61 views (last 30 days)
Omer Iqbal
Omer Iqbal on 11 Oct 2021
Commented: Omer Iqbal on 12 Oct 2021
Hi!
I am trying to do skeletonization and segmentation on binarized image. However, when I used the binarized image for this functions. It gives me an error. Please see an attachment for reference.
I shall be thankful for your suggestions!
Best
Omer

Answers (1)

Walter Roberson
Walter Roberson on 11 Oct 2021
Example:
IMG = imread('cameraman.tif');
size(IMG)
ans = 1×2
256 256
gr = rgb2gray(IMG);
Error using rgb2gray>parse_inputs (line 79)
MAP must be a m x 3 array. Use im2gray for RGB and grayscale images.

Error in rgb2gray (line 51)
isRGB = parse_inputs(X);
In other words, what you are passing to rgb2gray() is not an RGB image.
If you want to save a step in testing whether an input is already grayscale or not, you can substitute im2gray() for rgb2gray(): im2gray() will return arrays unchanged if they are already grayscale.
Note: binarized images are usually datatype logical() and already 2D. If you had a particular reason to convert them to grayscale then use im2double() or im2uint8()
  1 Comment
Omer Iqbal
Omer Iqbal on 12 Oct 2021
Thanks for your response!
Now , I am getting a new error after I gave the RGB image. Please see an attachment and codes below;
Select multiple Ridges files (they must be in a single folder)
Select multiple Ridges files (they must be in a single folder)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This is image 1 out of 1
Performing Otsu Thresholding Segmentation for Image 1 out of 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error using imadjust>parseInputs (line 215)
Specified syntax IMADJUST(I) is only supported for 2-D grayscale images. Additional input arguments are required for use
with RGB images.
Error in imadjust (line 105)
parseInputs(varargin{:});
Error in Ridge_Post_Processing (line 90)
imageIN_3 = imadjust(imageIN_2);
215 error(message('images:imadjust:oneArgOnlyGrayscale','IMADJUST(I)'))
K>>

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!