The approach I took was using MATLAB's functions, either [`regionprops()`][1] or [`bwconncomp()`][2] and [`bwdist()`][3]. The idea is to give a grade for each pixel which is a part of bad pixels object. The grade is the radius of the circle bounding the object the pixel resides in. One way to calculate the radius of the bounding circle is the `MajorAxisLength` property in the output of [`regionprops()`][1]. Another nice trick is using the [Binary Image Distance Transform][4]. If you apply the distance transform to the image where each bad pixels is black and the rest of the pixels is white, then for each object the maximum value represents the radius of the bounding image and the coordinate represent the center of the bounding circle. So for pixel I gave a grade and then summed the value of all pixels. The result is as expected: [![enter image description here][5]][5] [![enter image description here][6]][6] The score above completely ignores the content of the frame and only takes into account the map of the bad pixels. In real world application I'd do one extra step. I would take [Saliency Map][7] into account. Then for pixels which are in an important location I'd add more to their score. The full MATLAB code is available on my [StackExchange Signal Processing Q63549 GitHub Repository][8] (Look at the `SignalProcessing\Q63549` folder). [1]: https://www.mathworks.com/help/images/ref/regionprops.html [2]: https://www.mathworks.com/help/images/ref/bwconncomp.html [3]: https://www.mathworks.com/help/images/ref/bwdist.html [4]: https://en.wikipedia.org/wiki/Distance_transform [5]: https://i.sstatic.net/2D3wc.png [6]: https://i.sstatic.net/hBXpj.png [7]: https://en.wikipedia.org/wiki/Saliency_map [8]: https://github.com/RoyiAvital/StackExchangeCodes