Non-zero of Image
This block returns the total number of non-zero pixels found in an image. It is useful for quick measurements such as foreground pixel count, occupancy checks, or verifying mask coverage.
π₯ Inputs
Image Any Provide the image you want to analyze. The block accepts color or grayscale images.
π€ Outputs
Count Total number of non-zero pixels detected in the provided image.
πΉοΈ Controls
This block has no user-facing controls. It runs automatically when an image is provided.
β¨ Features
Fast single-value result useful for simple analytics and decision making.
Accepts both color and grayscale images (color images are internally interpreted for pixel activity).
Works well as a lightweight metric for masks, binary results, or foreground detection.
βοΈ Running mechanism
When the block is evaluated it examines the provided image and counts pixels that are non-zero (i.e., contain useful/foreground information). The result is returned as a single numeric value through the Count output.
π Usage
Connect an image-producing block to the
Image Anyinput.Read the numeric result from the
Countoutput to drive logic, logging, or alarms.Combine with other blocks for pre-processing, visualization, or decision-making.
π‘ Tips and Tricks
Prepare a clear binary mask before counting by using
Image ThresholdorImage Adaptive Thresholdto reduce false positives from noise.Use
Image ROIorImage ROI Selectto limit the counting area to a region of interest (for localized measurements).Reduce noise with
Blur,Bilateral FilterorDenoisingbefore counting to avoid inflated results.Visualize what is being counted by sending the same image to
Show Imageor overlay results withDraw Result On Image/Write Text On Image.Log numeric results over time using
CSV ExportorData to JSONfor trend analysis or record keeping.Combine with
Logic Inputor comparison blocks to trigger actions when the count crosses a threshold.
π οΈ Troubleshooting
Unexpectedly high counts: check for image noise or stray pixels. Apply
Image Thresholdand smoothing blocks to clean the input.Zero or very low counts: confirm the upstream image is valid using
Show Imageand ensure the area of interest contains the expected foreground.Counts vary unexpectedly between frames: restrict the area with
Image ROIor stabilize the input using filters to reduce frame-to-frame variation.
Last updated
Was this helpful?