Coverage for pyguymer3/image/makePngSrc/paethFilter.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-08 18:47 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def paethFilter( 

5 a, 

6 b, 

7 c, 

8 /, 

9): 

10 """The Path filter (as defined in the PNG specification [2]_). 

11 

12 Parameters 

13 ---------- 

14 a : numpy.int16 

15 See the PNG specification [2]_. 

16 b : numpy.int16 

17 See the PNG specification [2]_. 

18 c : numpy.int16 

19 See the PNG specification [2]_. 

20 

21 Returns 

22 ------- 

23 pr : numpy.int16 

24 See the PNG specification [2]_. 

25 

26 Notes 

27 ----- 

28 

29 Copyright 2017 Thomas Guymer [1]_ 

30 

31 References 

32 ---------- 

33 .. [1] PyGuymer3, https://github.com/Guymer/PyGuymer3 

34 .. [2] PNG Specification (Third Edition), https://www.w3.org/TR/png-3/ 

35 """ 

36 

37 # ************************************************************************** 

38 

39 # Find differences ... 

40 pi = a + b - c 

41 pa = abs(pi - a) 

42 pb = abs(pi - b) 

43 pc = abs(pi - c) 

44 

45 # Return best point ... 

46 if pa <= pb and pa <= pc: 

47 return a 

48 if pb <= pc: 

49 return b 

50 return c