Unrecognized function error.

3 visualizaciones (últimos 30 días)
Andrew Killian
Andrew Killian el 31 de Ag. de 2021
Respondida: Gargi Patil el 3 de Sept. de 2021
I just want to count the number of non-white pixels in an image.
I have
pix = imread('/binary_image4.png');
nonZeroPixels = nnz(pix);
But when I evaluate selection of second line, I get " Unrecognized function or variable 'pix'."
  1 comentario
per isakson
per isakson el 31 de Ag. de 2021
Editada: per isakson el 31 de Ag. de 2021
Why the slash, "/"? Try
pix = imread('binary_image4.png');
You use LINUX, I guess.
Make sure imread() succeeds.

Iniciar sesión para comentar.

Respuestas (1)

Gargi Patil
Gargi Patil el 3 de Sept. de 2021
Hi,
As mentioned in the comments, the forward slash in the path is not required. Ensure the image is on the MATLAB path or pass the required file path.
The code snippet shared works successfully for MATLAB's built-in demo binary image:
I = imread('circles.png');
nonZeroPixels = nnz(I)
nonZeroPixels = 14134

Categorías

Más información sobre Read, Write, and Modify Image 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