File: test_rle.py

package info (click to toggle)
gamera 1:3.4.2+git20160808.1725654-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 22,312 kB
  • ctags: 24,991
  • sloc: xml: 122,324; ansic: 52,869; cpp: 50,664; python: 35,034; makefile: 118; sh: 101
file content (33 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from gamera.core import *
init_gamera()

def test_rle1():
   image1 = load_image("data/testline.png")
   image2 = load_image("data/testline.png", RLE)

   # Check basic RLE image loading
   assert image2.pixel_type_name == "OneBit"
   assert image2.nrows == 44
   assert image2.ncols == 907
   assert image2.black_area()[0] == 5174.0

   # Compare RLE to DENSE image
   assert image1._to_raw_string() == image2._to_raw_string()
   assert image1.to_rle() == image2.to_rle()

   # Run something complicated, like cc_analysis
   image1.cc_analysis()
   image2.cc_analysis()

   # compare the results
   assert image1.color_ccs().to_string() == image2.color_ccs().to_string()
   assert image1._to_raw_string() == image2._to_raw_string()

   # Do some more complicated stuff, particularly things that
   # use iterators in unusual ways
   assert image1.projection_rows() == image2.projection_rows()
   assert image1.projection_cols() == image2.projection_cols()
   assert image1.most_frequent_run("black","vertical") == image2.most_frequent_run("black","vertical")
   assert image1.most_frequent_run("black","horizontal") == image2.most_frequent_run("black","horizontal")