@@ -54,7 +54,7 @@ public void FindBordersTest()
5454 {
5555 var stripe = flatImage . GetHorizontalStripe ( iy ) ;
5656 var derivative = FlatImage . GetDerivative ( stripe ) ;
57- var segments = FlatImage . FindZeroSegments ( derivative , minimalSegmentLength ) ;
57+ var segments = IntegerSegmentUtils . FindZeroSegments ( derivative , minimalSegmentLength ) ;
5858
5959 Assert . AreEqual ( 2 , segments . Count , String . Format ( "iy={0}" , iy ) ) ;
6060 }
@@ -73,120 +73,6 @@ public void FindBoundingsOfInnerImage()
7373 Assert . AreEqual ( 28 , result . Height ) ;
7474 }
7575
76- [ Test ]
77- public void FindZeroSegmentsTest1 ( )
78- {
79- var array = new UInt32 [ ] { 1 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 1 , 0 , 3 , 4 , 0 , 3 , 5 } ;
80- var result = FlatImage . FindZeroSegments ( array , 4 ) ;
81- Assert . AreEqual ( 1 , result . Count ) ;
82- Assert . AreEqual ( 1 , result [ 0 ] . Item1 ) ;
83- Assert . AreEqual ( 5 , result [ 0 ] . Item2 ) ;
84- }
85-
86- [ Test ]
87- public void FindZeroSegmentsTestThreeSegments ( )
88- {
89- var array = new UInt32 [ ] { 1 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 1 , 0 , 0 , 3 , 4 , 0 , 0 , 3 , 0 , 5 } ;
90- var result = FlatImage . FindZeroSegments ( array , 2 ) ;
91- Assert . AreEqual ( 3 , result . Count ) ;
92- Assert . AreEqual ( 1 , result [ 0 ] . Item1 ) ;
93- Assert . AreEqual ( 5 , result [ 0 ] . Item2 ) ;
94- Assert . AreEqual ( 9 , result [ 1 ] . Item1 ) ;
95- Assert . AreEqual ( 10 , result [ 1 ] . Item2 ) ;
96- Assert . AreEqual ( 13 , result [ 2 ] . Item1 ) ;
97- Assert . AreEqual ( 14 , result [ 2 ] . Item2 ) ;
98- }
99-
100- [ Test ]
101- public void FindZeroSegmentsTestNoSegments ( )
102- {
103- var array = new UInt32 [ ] { 1 , 0 , 0 , 1 , 2 , 3 } ;
104- var result = FlatImage . FindZeroSegments ( array , 3 ) ;
105- Assert . AreEqual ( 0 , result . Count ) ;
106- }
107-
108- [ Test ]
109- public void FindZeroSegmentsTestShortAllZeroSegment ( )
110- {
111- var array = new UInt32 [ ] { 0 , 0 , 0 , 0 , } ;
112- var result = FlatImage . FindZeroSegments ( array , 4 ) ;
113- Assert . AreEqual ( 1 , result . Count ) ;
114- Assert . AreEqual ( 0 , result [ 0 ] . Item1 ) ;
115- Assert . AreEqual ( 3 , result [ 0 ] . Item2 ) ;
116- }
117-
118- [ Test ]
119- public void FindZeroSegmentsTestAllZeroSegment ( )
120- {
121- var array = new UInt32 [ ] { 0 , 0 , 0 , 0 , 0 , 0 } ;
122- var result = FlatImage . FindZeroSegments ( array , 3 ) ;
123- Assert . AreEqual ( 1 , result . Count ) ;
124- Assert . AreEqual ( 0 , result [ 0 ] . Item1 ) ;
125- Assert . AreEqual ( 5 , result [ 0 ] . Item2 ) ;
126- }
127-
128- [ Test ]
129- public void FindZeroSegmentsTestSimpleSegment1 ( )
130- {
131- var array = new UInt32 [ ] { 1 , 0 , 0 , 0 , 0 , 0 } ;
132- var result = FlatImage . FindZeroSegments ( array , 3 ) ;
133- Assert . AreEqual ( 1 , result . Count ) ;
134- Assert . AreEqual ( 1 , result [ 0 ] . Item1 ) ;
135- Assert . AreEqual ( 5 , result [ 0 ] . Item2 ) ;
136- }
137-
138- [ Test ]
139- public void FindZeroSegmentsTestSimpleSegment2 ( )
140- {
141- var array = new UInt32 [ ] { 0 , 0 , 0 , 0 , 0 , 1 } ;
142- var result = FlatImage . FindZeroSegments ( array , 3 ) ;
143- Assert . AreEqual ( 1 , result . Count ) ;
144- Assert . AreEqual ( 0 , result [ 0 ] . Item1 ) ;
145- Assert . AreEqual ( 4 , result [ 0 ] . Item2 ) ;
146- }
147-
148- [ Test ]
149- public void IntersectionOfSegmentsFullIntersection ( )
150- {
151- var result = FlatImage . IntersectionOfSegments (
152- new Tuple < int , int > ( 1 , 2 ) ,
153- new Tuple < int , int > ( 1 , 2 ) ) ;
154- Assert . AreEqual ( new Tuple < int , int > ( 1 , 2 ) , result ) ;
155- }
156-
157- [ Test ]
158- public void IntersectionOfSegmentsPartialIntersection ( )
159- {
160- var a = new Tuple < int , int > ( 1 , 4 ) ;
161- var b = new Tuple < int , int > ( 2 , 8 ) ;
162-
163- Assert . AreEqual ( new Tuple < int , int > ( 2 , 4 ) , FlatImage . IntersectionOfSegments ( a , b ) ) ;
164- Assert . AreEqual ( new Tuple < int , int > ( 2 , 4 ) , FlatImage . IntersectionOfSegments ( b , a ) ) ;
165- }
166-
167- [ Test ]
168- public void IntersectionOfSegmentsNoIntersection ( )
169- {
170- var result = FlatImage . IntersectionOfSegments (
171- new Tuple < int , int > ( 1 , 2 ) ,
172- new Tuple < int , int > ( 4 , 5 ) ) ;
173- Assert . IsNull ( result ) ;
174- }
175-
176- [ Test ]
177- public void IntersectionOfSegments ( )
178- {
179- var result = FlatImage . IntersectionOfSegments ( new [ ]
180- {
181- new [ ] { new Tuple < int , int > ( 1 , 2 ) , new Tuple < int , int > ( 4 , 6 ) } ,
182- new [ ] { new Tuple < int , int > ( 1 , 2 ) , new Tuple < int , int > ( 5 , 10 ) } ,
183- } ) ;
184-
185- Assert . AreEqual ( 2 , result . Count ) ;
186- Assert . AreEqual ( new Tuple < int , int > ( 1 , 2 ) , result [ 0 ] ) ;
187- Assert . AreEqual ( new Tuple < int , int > ( 5 , 6 ) , result [ 1 ] ) ;
188- }
189-
19076 private static FlatImage LoadFlatImageFromResource ( string resourceName )
19177 {
19278 FlatImage flatImage ;
0 commit comments