Unrecognized function error.

2 次查看(过去 30 天)
Andrew Killian
Andrew Killian 2021-8-31
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
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

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by