2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef bbf_LOCAL_SCANNER_EM_H
18 #define bbf_LOCAL_SCANNER_EM_H
20 /* ---- includes ----------------------------------------------------------- */
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"
32 #include "b_BitFeatureEm/Feature.h"
33 #include "b_BitFeatureEm/BitParam.h"
35 /* ---- related objects --------------------------------------------------- */
37 /* ---- typedefs ----------------------------------------------------------- */
39 /* ---- constants ---------------------------------------------------------- */
41 /* data format version number */
42 #define bbf_LOCAL_SCANNER_VERSION 100
44 /* ---- object definition -------------------------------------------------- */
46 /** supports scanning an image on a fixed scale and provides patches on local areas as needed */
47 struct bbf_LocalScanner
49 /* ---- private data --------------------------------------------------- */
51 /** current scan x-coordinate */
54 /** current scan y-coordinate */
57 /** current xOffset */
60 /** current yOffset */
63 /** width of scaled image */
66 /** height of scaled image */
67 uint32 currentHeightE;
69 /** width of work image */
72 /** height of work image */
75 /** pointer to working image data */
76 const uint8* workImagePtrE;
78 /** width of original image */
81 /** height of original image */
84 /** pointer to original image data */
85 const uint8* origImagePtrE;
87 /** parameter for bit generation */
88 struct bbf_BitParam bitParamE;
90 /** work image (two pixels per uint16)*/
91 struct bbs_UInt8Arr workImageBufferE;
93 /** summed-area table (ring buffer) */
94 struct bim_UInt32Image satE;
97 struct bim_UInt32Image bitImageE;
100 struct bbs_UInt32Arr patchBufferE;
102 /** original scan region */
103 struct bts_Int16Rect origScanRegionE;
105 /** current scan region */
106 struct bts_Int16Rect workScanRegionE;
108 /* ---- public data ---------------------------------------------------- */
116 /** scale exponent (determines at which scale patch data is actually generated) */
119 /** max image width */
120 uint32 maxImageWidthE;
122 /** max image height */
123 uint32 maxImageHeightE;
125 /** min scale exponent */
128 /** maximum filter radius */
133 /* ---- associated objects ------------------------------------------------- */
135 /* ---- external functions ------------------------------------------------- */
137 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
139 /** initializes bbf_LocalScanner */
140 void bbf_LocalScanner_init( struct bbs_Context* cpA,
141 struct bbf_LocalScanner* ptrA );
143 /** resets bbf_LocalScanner */
144 void bbf_LocalScanner_exit( struct bbs_Context* cpA,
145 struct bbf_LocalScanner* ptrA );
147 /* ---- \ghd{ operators } -------------------------------------------------- */
150 void bbf_LocalScanner_copy( struct bbs_Context* cpA,
151 struct bbf_LocalScanner* ptrA,
152 const struct bbf_LocalScanner* srcPtrA );
154 /** equal operator */
155 flag bbf_LocalScanner_equal( struct bbs_Context* cpA,
156 const struct bbf_LocalScanner* ptrA,
157 const struct bbf_LocalScanner* srcPtrA );
159 /* ---- \ghd{ query functions } -------------------------------------------- */
161 /** total scan positions at current scale */
162 uint32 bbf_LocalScanner_positions( const struct bbf_LocalScanner* ptrA );
164 /** current scan index */
165 uint32 bbf_LocalScanner_scanIndex( const struct bbf_LocalScanner* ptrA );
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 );
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 );
173 /* ---- \ghd{ modify functions } ------------------------------------------- */
175 /** creates & initializes object */
176 void bbf_LocalScanner_create( struct bbs_Context* cpA,
177 struct bbf_LocalScanner* ptrA,
181 uint32 maxImageWidthA,
182 uint32 maxImageHeightA,
185 struct bbs_MemTbl* mtpA );
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 );
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
198 void bbf_LocalScanner_origScanRegion( struct bbs_Context* cpA,
199 struct bbf_LocalScanner* ptrA,
200 const struct bts_Int16Rect* scanRegionPtrA );
202 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
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 );
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 );
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 );
218 /* ---- \ghd{ exec functions } --------------------------------------------- */
220 /** resets scan position at current scale level */
221 void bbf_LocalScanner_resetScan( struct bbs_Context* cpA,
222 struct bbf_LocalScanner* ptrA );
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,
230 const struct bbf_BitParam* paramPtrA );
232 /** returns pointer to patch data */
233 const uint32* bbf_LocalScanner_getPatch( const struct bbf_LocalScanner* ptrA );
235 /** goes to next scan position */
236 flag bbf_LocalScanner_next( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA );
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 );
241 /** goes to scan position */
242 void bbf_LocalScanner_goToIndex( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA, uint32 scanIndexA );
244 /** goes to next offset position */
245 flag bbf_LocalScanner_nextOffset( struct bbs_Context* cpA, struct bbf_LocalScanner* ptrA );
247 #endif /* bbf_LOCAL_SCANNER_EM_H */