How can I find the most dense regions in an image?

前端 未结 4 509
面向向阳花
面向向阳花 2021-02-02 00:11

Consider a black and white image like this

\"alt

What I am trying to do is to find the region where

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 00:56

    Maybe a naive approach:

    You define a square of n*n which is the maximum size of the region in which you measure the density. For each point in the image you consider the point as the center of the square and count around the number of black (b) and white (w) points. Using the difference b-w you can determine in which square(s) is the most white.

    The most dense regions must be determined in a fuzzy way. If one region has 600 white points and another 599 then, for the human eye, they are the same density. 600 is 100% dense while 599 is 99% dense and 1% non-dense. Use an epsilon for this.

    n can be predefined or based on some function (ie. percent of image size).

    You could also use a circle/ellipse instead of square/rectangle. Choose what fits your needs best

提交回复
热议问题