rbg2gray problem when reading .png files

3 visualizaciones (últimos 30 días)
Rayne
Rayne el 1 de Nov. de 2015
Comentada: Rayne el 1 de Nov. de 2015
I'm trying to run the PCA code downloaded from here . I have no problems running with the provided images that are in .jpg. However, when I try to run with my own images (greyscale, in .png format), I keep getting the error
Error using rgb2gray>parse_inputs (line 77)
MAP must be a m x 3 array.
Error in rgb2gray (line 52)
[X, threeD] = parse_inputs(X);
Error in CreateDatabase (line 43)
img = rgb2gray(img);
Error in example (line 26)
T = CreateDatabase(TrainDatabasePath);
I even tried to convert the .png files to .jpg, first using imread to read the file, then imwrite to convert, but I still get the same error.
What is wrong?

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 1 de Nov. de 2015
Rayne - you say that you observe the above errors when you use your own greyscale images. Why would you call rgb2gray on an image that is already grayscale (and whose purpose is to Convert RGB image or colormap to grayscale)?
Look at the link to this method and check the input which is a three dimensional numeric array. Your grayscale images are most likely two dimensional only and so the above error message makes sense.
  1 comentario
Rayne
Rayne el 1 de Nov. de 2015
You're right. I don't know what I'm thinking! I commented out the line and the program works now. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by