Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2# coding=utf-8
5"""Test utilities"""
8import numpy
11def count_bw(b):
12 """Calculates totals of black and white pixels in a binary image
15 Parameters
16 ----------
18 b : PIL.Image.Image
19 A PIL image in mode "1" to be used for calculating positives and
20 negatives
22 Returns
23 -------
25 black : int
26 Number of black pixels in the binary image
28 white : int
29 Number of white pixels in the binary image
30 """
32 boolean_array = numpy.array(b)
33 white = boolean_array.sum()
34 return (boolean_array.size - white), white