I'm working on an application where I get a video frame that's already segmented into good and bad pixels (as in -- the hardware either coughs up a pixel value or a flag that says "bad"). I want to come up with a figure of merit for the frame that's based both on the number of bad pixels and the amount that they are clumped, with one big clump being worse than a bunch of little ones. All I can think to do is to walk the perimeter of each clump (really inefficient) or do an FFT and look for high frequency content (not terribly efficient, and not terribly accurate, either, I think). Are there known good ways to do this?