Unrecognized function error.

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 Commento

per isakson
per isakson il 31 Ago 2021
Modificato: per isakson il 31 Ago 2021
Why the slash, "/"? Try
pix = imread('binary_image4.png');
You use LINUX, I guess.
Make sure imread() succeeds.

Accedi per commentare.

Risposte (1)

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

Categorie

Scopri di più su Images in Centro assistenza e File Exchange

Tag

Richiesto:

il 31 Ago 2021

Risposto:

il 3 Set 2021

Community Treasure Hunt

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

Start Hunting!

Translated by