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

23+ years’ programming and theoretical experience in the computer science fields such as video compression, media streaming and artificial intelligence (co-author of several papers and patents).
the author is looking for new job, my resume