Unrecognized function error.

조회 수: 5 (최근 30일)
Andrew Killian
Andrew Killian . 2021년 8월 31일
답변: Gargi Patil . 2021년 9월 3일
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
per isakson
per isakson 2021년 8월 31일
편집: per isakson 님. 2021년 8월 31일
Why the slash, "/"? Try
pix = imread('binary_image4.png');
You use LINUX, I guess.
Make sure imread() succeeds.

댓글을 달려면 로그인하십시오.

답변 (1개)

Gargi Patil
Gargi Patil 2021년 9월 3일
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


Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by