Block flatness score (BF), which is specified as the ratio of absolute magnitude of DC to the sum of absolute values of transform coefficients, is sometimes used in CU partition decision methods, e.g. refer to the paper “Fast Intra CU Size Decision for HEVC Based on Machine Learning“, by Meng Wang, et al, 2018.

To compute the block flatness transform is not needed since DC is the average of all pixels in a block and the sum of squared transformed coefficients is equal the sum of squared pixel values:

Taken from the above-mentioned  article, here BF denotes the block flatness.

The block flatness takes values in the range [0..1], close to zero – very detailed area, close to 1 – very flat area.

The python script ComputePictureFlatness.py   takes input image in any format, converts it into YUV. Then Y-plane is divided into 8×8 blocks (chroma planes are ignored),  the block flatness is computed for each block. Finally the script calculates the median, 5%-percentile and 95%-percentile over all 8×8 blocks as indicators of the picture flatness.

Usage ComputePictureFlatness.py:

-i      input colored or monochrome image, e.g. in bmp-format (BGR)

 

Example:  for baboon-image (high-detailed)

python ComputePictureFlatness.py -i baboon.bmp
median BF 0.69
5-percentile 0.53
95-percentile 0.83

 

Example:  for pepper-image (flat image):

python ComputePictureFlatness.py -i pepper.bmp
median BF 0.83
5-percentile 0.60
95-percentile 1.00

Leave a Reply

Your email address will not be published. Required fields are marked *