Algorithm Pseudo Code
From ZoneMinder
Reading through the source code (Version 1.21), it appears that the evaluation algorithm for determining if an image represents an alarm condition goes something like this:
Start
Step through the pixels of one zone, row by row and create a map in black and white of each pixel that has changed (white) versus each pixel that has not (black). The criteria for determining if a pixel has changed, is that it must be different than the pixel in the reference (previous) frame and the difference must be greater than the min pixel threshold and less than the max pixel threshold.
Tally the total number of white (changed) pixels in the zone.
If there are no white (changed) pixels, then we are done. The image has not changed.
Check against min alarm pixels and max alarm pixels. If outside the limits, then the image has not changed. We are done.
Calculate the image score (percentage of alarm px to total px)
If Alarm Check Method is “Alarmed Pixels” then the number of alarm filtered pixels is set equal to the alarm pixels. Essentially skipping the algorithms for Filtering and Blobs.
- If the zone is an inclusive zone, then halve the score. (score=score/2)
- If the zone is an exclusive zone, then double the score. (score=score*2)
If Alarm Check Method is “Alarmed Pixels” then the image is evaluated by the score obtained at this point. Conclude that image has changed.
NEXT
If Alarm Check Method is “Filtered Pixels” (or "Blobs") then take the black and white map of changed pixels from the Alarmed Pixels tests and further analyze to produce a new black and white map of the changed pixels and a new tally of the number of changed pixels. The alarm filtered pixels is set equal to this new tally.
If there are no white (alarmed & filtered) pixels, then we are done. The image has not changed.
Check tally against min filter pixels and max filter pixels. If outside the limits, then the image has not changed. We are done.
Calculate the new image score (percentage of alarm&filter px to total px)
- If the zone is an inclusive zone, then halve the score. (score=score/2)
- If the zone is an exclusive zone, then double the score. (score=score*2)
If Alarm Check Method is “Filtered Pixels” then the image is evaluated by the score obtained at this point. Conclude that image has changed.
NEXT
If Alarm Check Method is “Blobs” then analyze the black and white map of the Alarm Check Method again, trying to homogenize the image. Drop some exteraneous white pixels, and convert a black pixel, surrounded by white into a white pixel. Join any Blobs that touch (have a common border) into a single blob. Tally the number of changed (white pixels) in the new analyzed image.
Calculate the new image score (percentage of alarm&filter&blob px to total px).
- If the zone is an inclusive zone, then halve the score. (score=score/2)
- If the zone is an exclusive zone, then double the score. (score=score*2)
If Alarm Check Method is “Blobs” then the image is evaluated by the score obtained at this point. Conclude that image has changed.


