• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef bbf_LOCAL_SCANNER_EM_H
18 #define bbf_LOCAL_SCANNER_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/Basic.h"
24 #include "b_BasicEm/UInt32Arr.h"
25 #include "b_BasicEm/Int32Arr.h"
26 #include "b_BasicEm/Int16Arr.h"
27 #include "b_BasicEm/MemTbl.h"
28 #include "b_BasicEm/UInt16Arr.h"
29 #include "b_TensorEm/Int16Rect.h"
30 #include "b_ImageEm/UInt32Image.h"
31 
32 #include "b_BitFeatureEm/Feature.h"
33 #include "b_BitFeatureEm/BitParam.h"
34 
35 /* ---- related objects  --------------------------------------------------- */
36 
37 /* ---- typedefs ----------------------------------------------------------- */
38 
39 /* ---- constants ---------------------------------------------------------- */
40 
41 /* data format version number */
42 #define bbf_LOCAL_SCANNER_VERSION 100
43 
44 /* ---- object definition -------------------------------------------------- */
45 
46 /** supports scanning an image on a fixed scale and provides patches on local areas as needed */
47 struct bbf_LocalScanner
48 {
49 	/* ---- private data --------------------------------------------------- */
50 
51 	/** current scan x-coordinate */
52 	int32 xE;
53 
54 	/** current scan y-coordinate */
55 	int32 yE;
56 
57 	/** current xOffset */
58 	int32 xOffE;
59 
60 	/** current yOffset */
61 	int32 yOffE;
62 
63 	/** width of scaled image */
64 	uint32 currentWidthE;
65 
66 	/** height of scaled image */
67 	uint32 currentHeightE;
68 
69 	/** width of work image */
70 	uint32 workWidthE;
71 
72 	/** height of work image */
73 	uint32 workHeightE;
74 
75 	/** pointer to working image data */
76 	const uint8* workImagePtrE;
77 
78 	/** width of original image */
79 	uint32 origWidthE;
80 
81 	/** height of original image */
82 	uint32 origHeightE;
83 
84 	/** pointer to original image data */
85 	const uint8* origImagePtrE;
86 
87 	/** parameter for bit generation */
88 	struct bbf_BitParam bitParamE;
89 
90 	/** work image (two pixels per uint16)*/
91 	struct bbs_UInt8Arr workImageBufferE;
92 
93 	/** summed-area table (ring buffer) */
94 	struct bim_UInt32Image satE;
95 
96 	/** bit image */
97 	struct bim_UInt32Image bitImageE;
98 
99 	/** patch buffer */
100 	struct bbs_UInt32Arr patchBufferE;
101 
102 	/** original scan region */
103 	struct bts_Int16Rect origScanRegionE;
104 
105 	/** current scan region */
106 	struct bts_Int16Rect workScanRegionE;
107 
108 	/* ---- public data ---------------------------------------------------- */
109 
110 	/** patch width */
111 	uint32 patchWidthE;
112 
113 	/** patch height */
114 	uint32 patchHeightE;
115 
116 	/** scale exponent (determines at which scale patch data is actually generated) */
117 	uint32 scaleExpE;
118 
119 	/** max image width */
120 	uint32 maxImageWidthE;
121 
122 	/** max image height */
123 	uint32 maxImageHeightE;
124 
125 	/** min scale exponent */
126 	uint32 minScaleExpE;
127 
128 	/** maximum filter radius */
129 	uint32 maxRadiusE;
130 
131 };
132 
133 /* ---- associated objects ------------------------------------------------- */
134 
135 /* ---- external functions ------------------------------------------------- */
136 
137 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
138 
139 /** initializes bbf_LocalScanner  */
140 void bbf_LocalScanner_init( struct bbs_Context* cpA,
141 							struct bbf_LocalScanner* ptrA );
142 
143 /** resets bbf_LocalScanner  */
144 void bbf_LocalScanner_exit( struct bbs_Context* cpA,
145 							struct bbf_LocalScanner* ptrA );
146 
147 /* ---- \ghd{ operators } -------------------------------------------------- */
148 
149 /** copy operator */
150 void bbf_LocalScanner_copy( struct bbs_Context* cpA,
151 							struct bbf_LocalScanner* ptrA,
152 							const struct bbf_LocalScanner* srcPtrA );
153 
154 /** equal operator */
155 flag bbf_LocalScanner_equal( struct bbs_Context* cpA,
156 							 const struct bbf_LocalScanner* ptrA,
157 							 const struct bbf_LocalScanner* srcPtrA );
158 
159 /* ---- \ghd{ query functions } -------------------------------------------- */
160 
161 /** total scan positions at current scale */
162 uint32 bbf_LocalScanner_positions( const struct bbf_LocalScanner* ptrA );
163 
164 /** current scan index */
165 uint32 bbf_LocalScanner_scanIndex( const struct bbf_LocalScanner* ptrA );
166 
167 /** returns ul position relative to original image; x,y coordinates: 16.16 */
168 void bbf_LocalScanner_pos( const struct bbf_LocalScanner* ptrA, int32* xPtrA, int32* yPtrA );
169 
170 /** returns uls position relative to original image at index position; x,y coordinates: 16.16 */
171 void bbf_LocalScanner_idxPos( const struct bbf_LocalScanner* ptrA, uint32 scanIndexA, int32* xPtrA, int32* yPtrA );
172 
173 /* ---- \ghd{ modify functions } ------------------------------------------- */
174 
175 /** creates & initializes object */
176 void bbf_LocalScanner_create( struct bbs_Context* cpA,
177 							  struct bbf_LocalScanner* ptrA,
178 							  uint32 patchWidthA,
179 							  uint32 patchHeightA,
180 							  uint32 scaleExpA,
181 							  uint32 maxImageWidthA,
182 							  uint32 maxImageHeightA,
183 							  uint32 minScaleExpA,
184 							  uint32 maxRadiusA,
185 							  struct bbs_MemTbl* mtpA );
186 
187 /** parameter for bit generation + recomputing bit image */
188 void bbf_LocalScanner_bitParam( struct bbs_Context* cpA,
189 							    struct bbf_LocalScanner* ptrA,
190 								const struct bbf_BitParam* bitParamPtrA );
191 
192 /** Specifies a (sub-) scan region
193  *  Scanning within a given scale is limited to that region.
194  *  Region is truncateed to physical region
195  *  Image assignment, bitParam assignment and function nextScale reset the sacn region to
196  *  the whole image.
197  */
198 void bbf_LocalScanner_origScanRegion( struct bbs_Context* cpA,
199 									  struct bbf_LocalScanner* ptrA,
200 									  const struct bts_Int16Rect* scanRegionPtrA );
201 
202 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
203 
204 /** word size (16-bit) object needs when written to memory */
205 uint32 bbf_LocalScanner_memSize( struct bbs_Context* cpA,
206 						         const struct bbf_LocalScanner* ptrA );
207 
208 /** writes object to memory; returns number of words (16-bit) written */
209 uint32 bbf_LocalScanner_memWrite( struct bbs_Context* cpA,
210 								  const struct bbf_LocalScanner* ptrA, uint16* memPtrA );
211 
212 /** reads object from memory; returns number of words (16-bit) read */
213 uint32 bbf_LocalScanner_memRead( struct bbs_Context* cpA,
214 								 struct bbf_LocalScanner* ptrA,
215 								 const uint16* memPtrA,
216 								 struct bbs_MemTbl* mtpA );
217 
218 /* ---- \ghd{ exec functions } --------------------------------------------- */
219 
220 /** resets scan position at current scale level */
221 void bbf_LocalScanner_resetScan( struct bbs_Context* cpA,
222 								 struct bbf_LocalScanner* ptrA );
223 
224 /** assigns image; sets initial bit parameters; resets processor */
225 void bbf_LocalScanner_assign( struct bbs_Context* cpA,
226 							  struct bbf_LocalScanner* ptrA,
227 							  const uint8* imagePtrA,
228 							  uint32 imageWidthA,
229 							  uint32 imageHeightA,
230 							  const struct bbf_BitParam* paramPtrA );
231 
232 /** returns pointer to patch data */
233 const uint32* bbf_LocalScanner_getPatch( const struct bbf_LocalScanner* ptrA );
234 
235 /** goes to next scan position */
236 flag bbf_LocalScanner_next( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA );
237 
238 /** goes to scan position (integer coordinate numbers) */
239 void bbf_LocalScanner_goToXY( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA, int32 xA, int32 yA );
240 
241 /** goes to scan position */
242 void bbf_LocalScanner_goToIndex( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA, uint32 scanIndexA );
243 
244 /** goes to next offset position */
245 flag bbf_LocalScanner_nextOffset( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA );
246 
247 #endif /* bbf_LOCAL_SCANNER_EM_H */
248 
249