A device includes at least one processor and memory including instructions that when executed by the at least one processor, cause the at least one processor to scan an input image including pixels that have either a first state or a second state opposite the first state, initiate a first cluster and a first polygon that belongs to the first cluster upon encountering a first pixel of the input image that has the first state, execute a first set of operations to form the first polygon, generate an indication of one or more characteristics of the input image based on at least the first cluster, and output the indication.