Coverage for /scratch/builds/bob/bob.ip.binseg/miniconda/conda-bld/bob.ip.binseg_1673966692152/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/lib/python3.10/site-packages/bob/ip/common/test/utils.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.0.5, created at 2023-01-17 15:03 +0000

1#!/usr/bin/env python 

2# coding=utf-8 

3 

4 

5"""Test utilities""" 

6 

7 

8import numpy 

9 

10 

11def count_bw(b): 

12 """Calculates totals of black and white pixels in a binary image 

13 

14 

15 Parameters 

16 ---------- 

17 

18 b : PIL.Image.Image 

19 A PIL image in mode "1" to be used for calculating positives and 

20 negatives 

21 

22 Returns 

23 ------- 

24 

25 black : int 

26 Number of black pixels in the binary image 

27 

28 white : int 

29 Number of white pixels in the binary image 

30 """ 

31 

32 boolean_array = numpy.array(b) 

33 white = boolean_array.sum() 

34 return (boolean_array.size - white), white