• 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 bts_RBFMAP2D_EM_H
18 #define bts_RBFMAP2D_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/Basic.h"
24 #include "b_BasicEm/Int16Arr.h"
25 #include "b_TensorEm/Int16Vec2D.h"
26 #include "b_TensorEm/Flt16Vec2D.h"
27 #include "b_TensorEm/Flt16Alt2D.h"
28 #include "b_TensorEm/Functions.h"
29 #include "b_TensorEm/Cluster2D.h"
30 #include "b_TensorEm/Int32Mat.h"
31 
32 /* ---- related objects  --------------------------------------------------- */
33 
34 /* ---- typedefs ----------------------------------------------------------- */
35 
36 /* ---- constants ---------------------------------------------------------- */
37 
38 /* data format version number */
39 #define bts_IRBFMAP2D_VERSION 100
40 
41 /* ---- object definition -------------------------------------------------- */
42 
43 /**
44  * radial basis function transformation (RBF).
45  * T( x ) = A( x ) + R( x ) where,
46  * T is the resulting overall tranformation
47  * A is a possibly linear tranformation of type altTypeE
48  * R is the rbf ( non-linear ) transformation of type typeE
49  * See member declaration for more information on typeE and altTypeE.
50  * See also
51  * 'Image Warping Using few Anchor Points and Radial Functions',
52  * Nur Arad and Daniel Reisfeld, 1994
53  */
54 struct bts_RBFMap2D
55 {
56 	/* ---- private data --------------------------------------------------- */
57 
58 	/* ---- public data ---------------------------------------------------- */
59 
60     /** type of radial basis function (enum bts_RBFType).
61 	 * one of:
62 	 * bts_RBF_IDENTITY   : no rbf deformation
63 	 * bts_RBF_LINEAr     : linear, i.e. ||r||
64 	 */
65 	int32 RBFTypeE;
66 
67 	/** src cluster, part of the RBF trafo */
68 	struct bts_Cluster2D srcClusterE;
69 
70 	/** cluster of rbf coefficients, x and y */
71 	struct bts_Cluster2D rbfCoeffClusterE;
72 
73     /** type of linear transformation (enum bts_AltType) */
74 	int32 altTypeE;
75 
76     /** affine linear transformation */
77 	struct bts_Flt16Alt2D altE;
78 
79 	/** apply only affine lnear transformation */
80 	flag altOnlyE;
81 
82 	/* ---- temporary data ------------------------------------------------- */
83 
84 	/** matrix needed for computation of rbf coefficients */
85 	struct bts_Int32Mat matE;
86 	struct bts_Int32Mat tempMatE;
87 
88 	/** arrays needed for computation of rbf coefficients */
89 	struct bbs_Int32Arr inVecE;
90 	struct bbs_Int32Arr outVecE;
91 	struct bbs_Int32Arr tempVecE;
92 };
93 
94 /* ---- associated objects ------------------------------------------------- */
95 
96 /* ---- external functions ------------------------------------------------- */
97 
98 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
99 
100 /** initializes RBFMap */
101 void bts_RBFMap2D_init( struct bbs_Context* cpA,
102 					    struct bts_RBFMap2D* ptrA );
103 
104 /** destroys RBFMap */
105 void bts_RBFMap2D_exit( struct bbs_Context* cpA,
106 					    struct bts_RBFMap2D* ptrA );
107 
108 /* ---- \ghd{ operators } -------------------------------------------------- */
109 
110 /** copies RBFMap */
111 void bts_RBFMap2D_copy( struct bbs_Context* cpA,
112 					    struct bts_RBFMap2D* ptrA,
113 						const struct bts_RBFMap2D* srcPtrA );
114 
115 /** compares RBFMap */
116 flag bts_RBFMap2D_equal( struct bbs_Context* cpA,
117 						 const struct bts_RBFMap2D* ptrA,
118 						 const struct bts_RBFMap2D* srcPtrA );
119 
120 /* ---- \ghd{ query functions } -------------------------------------------- */
121 
122 /* ---- \ghd{ modify functions } ------------------------------------------- */
123 
124 /** allocates RBFMap */
125 void bts_RBFMap2D_create( struct bbs_Context* cpA,
126 						  struct bts_RBFMap2D* ptrA,
127 						  uint32 sizeA,
128 				          struct bbs_MemSeg* mspA );
129 
130 /** computes rbf transform from 2 given clusters of same size and bbp */
131 void bts_RBFMap2D_compute( struct bbs_Context* cpA,
132 						   struct bts_RBFMap2D* ptrA,
133 						   const struct bts_Cluster2D* srcPtrA,
134 						   const struct bts_Cluster2D* dstPtrA );
135 
136 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
137 
138 /** size object needs when written to memory */
139 uint32 bts_RBFMap2D_memSize( struct bbs_Context* cpA,
140 							 const struct bts_RBFMap2D* ptrA );
141 
142 /** writes object to memory; returns number of bytes written */
143 uint32 bts_RBFMap2D_memWrite( struct bbs_Context* cpA,
144 							  const struct bts_RBFMap2D* ptrA,
145 							  uint16* memPtrA );
146 
147 /** reads object from memory; returns number of bytes read */
148 uint32 bts_RBFMap2D_memRead( struct bbs_Context* cpA,
149 							 struct bts_RBFMap2D* ptrA,
150 							 const uint16* memPtrA,
151 				             struct bbs_MemSeg* mspA );
152 
153 /* ---- \ghd{ exec functions } --------------------------------------------- */
154 
155 /** vector map operation: apply rbf to a vector */
156 struct bts_Flt16Vec2D bts_RBFMap2D_mapVector( struct bbs_Context* cpA,
157 											  const struct bts_RBFMap2D* ptrA,
158 											  struct bts_Flt16Vec2D vecA );
159 
160 /** cluster map operation: apply rbf to all vectors in cluster */
161 void bts_RBFMap2D_mapCluster( struct bbs_Context* cpA,
162 							  const struct bts_RBFMap2D* ptrA,
163 							  const struct bts_Cluster2D* srcPtrA,
164 							  struct bts_Cluster2D* dstPtrA,
165 							  int32 dstBbpA );
166 
167 #endif /* bts_RBFMAP2D_EM_H */
168 
169