Changeset 823 for soft/giet_vm/applications/rosenfeld/nrc2/src/nrlut.c
- Timestamp:
- Jun 14, 2016, 5:23:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/nrc2/src/nrlut.c
r821 r823 13 13 14 14 /* 15 * 2002/06/11 ajout des fonctions endline16 */15 * 2002/06/11 ajout des fonctions endline 16 */ 17 17 #include <stdio.h> 18 18 #include <stddef.h> … … 28 28 #include "nrlut.h" 29 29 30 /* ----------------------------------------------------------------------- */ 31 IMAGE_EXPORT(void) init_blut(byte *v, int nl, int nh, int n0, int n1, byte k) 32 /* ----------------------------------------------------------------------- */ 33 { 34 int i; 35 36 if(nl<=nh) { 37 // normal case 38 for(i=nl; i< n0; i++) v[i] = 0; 39 for(i=n0; i<=n1; i++) v[i] = k; 40 for(i=n1+1; i<nh; i++) v[i] = 0; 41 } else { 42 for(i=nl; i< n1; i++) v[i] = k; 43 for(i=n1; i<=n0; i++) v[i] = 0; 44 for(i=n1+1; i<nh; i++) v[i] = k; 45 } 46 } 47 /* ------------------------------------------------------------------------ */ 48 IMAGE_EXPORT(void) init_ui8lut(uint8 *v, int nl, int nh, int n0, int n1, uint8 k) 49 /* ------------------------------------------------------------------------ */ 50 { 51 int i; 52 53 if(nl<=nh) { 54 // normal case 55 for(i=nl; i< n0; i++) v[i] = 0; 56 for(i=n0; i<=n1; i++) v[i] = k; 57 for(i=n1+1; i<nh; i++) v[i] = 0; 58 } else { 59 for(i=nl; i< n1; i++) v[i] = k; 60 for(i=n1; i<=n0; i++) v[i] = 0; 61 for(i=n1+1; i<nh; i++) v[i] = k; 62 } 63 } 64 /* --------------------------------------------------------------------------- */ 65 IMAGE_EXPORT(void) init_ui16lut(uint16 *v, int nl, int nh, int n0, int n1, uint16 k) 66 /* --------------------------------------------------------------------------- */ 67 { 68 int i; 69 70 if(nl<=nh) { 71 // normal case 72 for(i=nl; i< n0; i++) v[i] = 0; 73 for(i=n0; i<=n1; i++) v[i] = k; 74 for(i=n1+1; i<=nh; i++) v[i] = 0; 75 } else { 76 for(i=nl; i< n1; i++) v[i] = k; 77 for(i=n1; i<=n0; i++) v[i] = 0; 78 for(i=n1+1; i<=nh; i++) v[i] = k; 79 } 80 } 81 /* --------------------------------------------------------------------------- */ 82 IMAGE_EXPORT(void) init_si16lut(sint16 *v, int nl, int nh, int n0, int n1, sint16 k) 83 /* --------------------------------------------------------------------------- */ 84 { 85 int i; 86 87 if(nl<=nh) { 88 // normal case 89 for(i=nl; i< n0; i++) v[i] = 0; 90 for(i=n0; i<=n1; i++) v[i] = k; 91 for(i=n1+1; i<=nh; i++) v[i] = 0; 92 } else { 93 for(i=nl; i< n1; i++) v[i] = k; 94 for(i=n1; i<=n0; i++) v[i] = 0; 95 for(i=n1+1; i<=nh; i++) v[i] = k; 96 } 97 } 98 /* --------------------------------------------------------------------------- */ 99 IMAGE_EXPORT(void) init_ui32lut(uint32 *v, int nl, int nh, int n0, int n1, uint32 k) 100 /* --------------------------------------------------------------------------- */ 101 { 102 int i; 103 104 if(nl<=nh) { 105 // normal case 106 for(i=nl; i< n0; i++) v[i] = 0; 107 for(i=n0; i<=n1; i++) v[i] = k; 108 for(i=n1+1; i<=nh; i++) v[i] = 0; 109 } else { 110 for(i=nl; i< n1; i++) v[i] = k; 111 for(i=n1; i<=n0; i++) v[i] = 0; 112 for(i=n1+1; i<=nh; i++) v[i] = k; 113 } 114 } 115 /* --------------------------------------------------------------------------- */ 116 IMAGE_EXPORT(void) init_i32lut(sint32 *v, int nl, int nh, int n0, int n1, sint32 k) 117 /* --------------------------------------------------------------------------- */ 118 { 119 int i; 120 121 if(nl<=nh) { 122 // normal case 123 for(i=nl; i< n0; i++) v[i] = 0; 124 for(i=n0; i<=n1; i++) v[i] = k; 125 for(i=n1+1; i<=nh; i++) v[i] = 0; 126 } else { 127 for(i=nl; i< n1; i++) v[i] = k; 128 for(i=n1; i<=n0; i++) v[i] = 0; 129 for(i=n1+1; i<=nh; i++) v[i] = k; 130 } 131 } 132 /* -------------------------------------------------------------------------- */ 133 IMAGE_EXPORT(void) init_rgb8lut(rgb8 *v, int nl, int nh, int n0, int n1, rgb8 k) 134 /* -------------------------------------------------------------------------- */ 135 { 136 int i; 137 138 if(nl<=nh) { 139 // normal case 140 for(i=nl; i< n0; i++) { v[i].r = 0; v[i].g = 0; v[i].b = 0;} 141 for(i=n0; i<=n1; i++) { v[i].r = k.r; v[i].g = k.g; v[i].b = k.b;} 142 for(i=n1+1; i<=nh; i++) { v[i].r = 0; v[i].g = 0; v[i].b = 0;} 143 } else { 144 for(i=nl; i< n1; i++) { v[i].r = k.r; v[i].g = k.g; v[i].b = k.b;} 145 for(i=n1; i<=n0; i++) { v[i].r = 0; v[i].g = 0; v[i].b = 0;} 146 for(i=n1+1; i<=nh; i++) { v[i].r = k.r; v[i].g = k.g; v[i].b = k.b;} 147 } 148 } 149 /* ------------------------------------------------------------------------------------------- */ 150 IMAGE_EXPORT(void) lut_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch, byte *L, byte **D) 151 /* ------------------------------------------------------------------------------------------- */ 152 { 153 int i, j; 154 155 for(i=nrl; i<=nrh; i++) { 156 for(j=ncl; j<=nch; j++) { 157 D[i][j] = L[(int)S[i][j]]; 158 } 159 } 160 } 161 /* -------------------------------------------------------------------------------------------- */ 162 IMAGE_EXPORT(void) lut_ui8matrix(uint8 **S, long nrl,long nrh,long ncl, long nch, uint8 *L, uint8 **D) 163 /* -------------------------------------------------------------------------------------------- */ 164 { 165 int i, j; 166 167 for(i=nrl; i<=nrh; i++) { 168 for(j=ncl; j<=nch; j++) { 169 D[i][j] = L[(int)S[i][j]]; 170 } 171 } 172 } 173 /* -------------------------------------------------------------------------------------------- */ 174 IMAGE_EXPORT(void) lut_si8matrix(sint8 **S, long nrl,long nrh,long ncl, long nch, sint8 *L, sint8 **D) 175 /* -------------------------------------------------------------------------------------------- */ 176 { 177 int i, j; 178 179 for(i=nrl; i<=nrh; i++) { 180 for(j=ncl; j<=nch; j++) { 181 D[i][j] = L[(int)S[i][j]]; 182 } 183 } 184 } 185 /* -------------------------------------------------------------------------------------------------- */ 186 IMAGE_EXPORT(void) lut_ui16matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, uint16 *L, uint16 **D) 187 /* -------------------------------------------------------------------------------------------------- */ 188 { 189 int i, j; 190 191 for(i=nrl; i<=nrh; i++) { 192 for(j=ncl; j<=nch; j++) { 193 D[i][j] = L[(int)S[i][j]]; 194 } 195 } 196 } 197 /* -------------------------------------------------------------------------------------------------- */ 198 IMAGE_EXPORT(void) lut_si16matrix(sint16 **S, long nrl, long nrh, long ncl, long nch, sint16 *L, sint16 **D) 199 /* -------------------------------------------------------------------------------------------------- */ 200 { 201 int i, j; 202 203 for(i=nrl; i<=nrh; i++) { 204 for(j=ncl; j<=nch; j++) { 205 D[i][j] = L[(int)S[i][j]]; 206 } 207 } 208 } 209 /* -------------------------------------------------------------------------------------------------- */ 210 IMAGE_EXPORT(void) lut_ui32matrix(uint32 **S, long nrl, long nrh, long ncl, long nch, uint32 *L, uint32 **D) 211 /* -------------------------------------------------------------------------------------------------- */ 212 { 213 int i, j; 214 215 for(i=nrl; i<=nrh; i++) { 216 for(j=ncl; j<=nch; j++) { 217 D[i][j] = L[(int)S[i][j]]; 218 } 219 } 220 } 221 /* -------------------------------------------------------------------------------------------------- */ 222 IMAGE_EXPORT(void) lut_si32matrix(sint32 **S, long nrl, long nrh, long ncl, long nch, sint32 *L, sint32 **D) 223 /* -------------------------------------------------------------------------------------------------- */ 224 { 225 int i, j; 226 227 for(i=nrl; i<=nrh; i++) { 228 for(j=ncl; j<=nch; j++) { 229 D[i][j] = L[(int)S[i][j]]; 230 } 231 } 232 } 233 /* ------------------------------------------------------------------------------------------------ */ 234 IMAGE_EXPORT(void) lut_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb8 *L, rgb8 **D) 235 /* ------------------------------------------------------------------------------------------------ */ 236 { 237 int i, j; 238 239 for(i=nrl; i<=nrh; i++) { 240 for(j=ncl; j<=nch; j++) { 241 D[i][j].r = L[S[i][j].r].r; 242 D[i][j].g = L[S[i][j].g].g; 243 D[i][j].b = L[S[i][j].b].b; 244 } 245 } 246 } 247 /* --------------------------------------------------------------------------------------------------------- */ 248 IMAGE_EXPORT(void) lut_ui16matrix_ui8matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, uint8 *L, uint8 **D) 249 /* --------------------------------------------------------------------------------------------------------- */ 250 { 251 int i, j; 252 253 for(i=nrl; i<=nrh; i++) { 254 for(j=ncl; j<=nch; j++) { 255 D[i][j] = L[(int)S[i][j]]; 256 } 257 } 258 } 259 /* --------------------------------------------------------------------------------------------------------- */ 260 IMAGE_EXPORT(void) lut_ui32matrix_ui16matrix(uint32 **S, long nrl, long nrh, long ncl, long nch, uint16 *L, uint16 **D) 261 /* --------------------------------------------------------------------------------------------------------- */ 262 { 263 int i, j; 264 265 for(i=nrl; i<=nrh; i++) { 266 for(j=ncl; j<=nch; j++) { 267 D[i][j] = L[(int)S[i][j]]; 268 } 269 } 270 } 271 /* ---------------------------------------------------------------------------- */ 272 IMAGE_EXPORT(void) histogram_bmatrix(byte **S, long nrl, long nrh, long ncl, long nch, int32 *H) 273 /* ---------------------------------------------------------------------------- */ 274 { 275 int i, j; 276 byte *Si; 277 278 for(i=nrl; i<=nrh; i++) { 279 Si = S[i]; 280 for(j=ncl; j<=nch; j++) { 281 H[(int) Si[j]]++; 282 } 283 } 284 } 285 /* --------------------------------------------------------------------------------- */ 286 IMAGE_EXPORT(void) histogram_ui16matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, int32 *H) 287 /* --------------------------------------------------------------------------------- */ 288 { 289 int i, j; 290 uint16 *Si; 291 292 for(i=nrl; i<=nrh; i++) { 293 Si = S[i]; 294 for(j=ncl; j<=nch; j++) { 295 H[Si[j]]++; 296 } 297 } 298 } 299 /* ------------------------------------------------------------------------------- */ 300 IMAGE_EXPORT(void) histogram_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb32 *H) 301 /* ------------------------------------------------------------------------------- */ 302 { 303 int i, j; 304 rgb8 *Si; 305 int r, b, g; 30 31 #undef init_type_lut 32 #define init_type_lut(t) \ 33 void short_name(t,init_,lut)(t * v, int32_t nl, int32_t nh, int32_t n0, int32_t n1, t k) \ 34 { \ 35 if (nl <= nh) { \ 36 for (int32_t i = nl; i < n0; i++) { \ 37 v[i] = 0; \ 38 } \ 39 for (int32_t i = n0; i <= n1; i++) { \ 40 v[i] = k; \ 41 } \ 42 for (int32_t i = n1 + 1; i <= nh; i++) { \ 43 v[i] = 0; \ 44 } \ 45 } \ 46 else { \ 47 for (int32_t i = nl; i < n1; i++) { \ 48 v[i] = k; \ 49 } \ 50 for (int32_t i = n1; i <= n0; i++) { \ 51 v[i] = 0; \ 52 } \ 53 for (int32_t i = n1 + 1; i <= nh; i++) { \ 54 v[i] = k; \ 55 } \ 56 } \ 57 } 58 59 60 init_type_lut(int8_t); 61 init_type_lut(uint8_t); 62 init_type_lut(int16_t); 63 init_type_lut(uint16_t); 64 init_type_lut(int32_t); 65 init_type_lut(uint32_t); 66 67 68 69 void init_rgb8lut(rgb8 * v, int32_t nl, int32_t nh, int32_t n0, int32_t n1, rgb8 k) 70 { 71 if (nl <= nh) { 72 // normal case 73 for (int32_t i = nl; i < n0; i++) { 74 v[i].r = 0; 75 v[i].g = 0; 76 v[i].b = 0; 77 } 78 for (int32_t i = n0; i <= n1; i++) { 79 v[i].r = k.r; 80 v[i].g = k.g; 81 v[i].b = k.b; 82 } 83 for (int32_t i = n1 + 1; i <= nh; i++) { 84 v[i].r = 0; 85 v[i].g = 0; 86 v[i].b = 0; 87 } 88 } 89 else { 90 for (int32_t i = nl; i < n1; i++) { 91 v[i].r = k.r; 92 v[i].g = k.g; 93 v[i].b = k.b; 94 } 95 for (int32_t i = n1; i <= n0; i++) { 96 v[i].r = 0; 97 v[i].g = 0; 98 v[i].b = 0; 99 } 100 for (int32_t i = n1 + 1; i <= nh; i++) { 101 v[i].r = k.r; 102 v[i].g = k.g; 103 v[i].b = k.b; 104 } 105 } 106 } 107 108 109 #undef lut_type_matrix 110 #define lut_type_matrix(t) \ 111 void short_name(t,lut_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * L, t ** D) \ 112 { \ 113 for (int32_t i = nrl; i <= nrh; i++) { \ 114 for (int32_t j = ncl; j <= nch; j++) { \ 115 D[i][j] = L[(int32_t) S[i][j]]; \ 116 } \ 117 } \ 118 } 119 120 lut_type_matrix(int8_t); 121 lut_type_matrix(uint8_t); 122 lut_type_matrix(int16_t); 123 lut_type_matrix(uint16_t); 124 lut_type_matrix(int32_t); 125 lut_type_matrix(uint32_t); 126 127 128 129 void lut_rgb8matrix(rgb8 ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 * L, rgb8 ** D) 130 { 131 for (int32_t i = nrl; i <= nrh; i++) { 132 for (int32_t j = ncl; j <= nch; j++) { 133 D[i][j].r = L[S[i][j].r].r; 134 D[i][j].g = L[S[i][j].g].g; 135 D[i][j].b = L[S[i][j].b].b; 136 } 137 } 138 } 139 140 141 void lut_ui16matrix_ui8matrix(uint16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t * L, uint8_t ** D) 142 { 143 for (int32_t i = nrl; i <= nrh; i++) { 144 for (int32_t j = ncl; j <= nch; j++) { 145 D[i][j] = L[(int32_t) S[i][j]]; 146 } 147 } 148 } 149 150 void lut_i16matrix_i8matrix(int16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t * L, int8_t ** D) 151 { 152 for (int32_t i = nrl; i <= nrh; i++) { 153 for (int32_t j = ncl; j <= nch; j++) { 154 D[i][j] = L[(int32_t) S[i][j]]; 155 } 156 } 157 } 158 159 void lut_ui32matrix_ui16matrix(uint32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint16_t * L, uint16_t ** D) 160 { 161 for (int32_t i = nrl; i <= nrh; i++) { 162 for (int32_t j = ncl; j <= nch; j++) { 163 D[i][j] = L[(int32_t) S[i][j]]; 164 } 165 } 166 } 167 168 void lut_i32matrix_i16matrix(int32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint16_t * L, int16_t ** D) 169 { 170 for (int32_t i = nrl; i <= nrh; i++) { 171 for (int32_t j = ncl; j <= nch; j++) { 172 D[i][j] = L[(int32_t) S[i][j]]; 173 } 174 } 175 } 176 177 178 #undef histogram_type_matrix 179 #define histogram_type_matrix(t) \ 180 void short_name(t,histogram_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * H) \ 181 { \ 182 t * Si; \ 183 for (int32_t i = nrl; i <= nrh; i++) { \ 184 Si = S[i]; \ 185 for (int32_t j = ncl; j <= nch; j++) { \ 186 H[(int32_t) Si[j]]++; \ 187 } \ 188 } \ 189 } 190 191 histogram_type_matrix(int8_t); 192 histogram_type_matrix(uint8_t); 193 histogram_type_matrix(int16_t); 194 histogram_type_matrix(uint16_t); 195 histogram_type_matrix(int32_t); 196 histogram_type_matrix(uint32_t); 197 198 199 200 void histogram_rgb8matrix(rgb8 ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 * H) 201 { 202 rgb8 * Si; 203 int r, b, g; 306 204 (void) Si; 307 308 //FUNCTION_NAME("Histogram_rgbmatrix"); 309 310 for(i=nrl; i<=nrh; i++) { 311 Si = S[i]; 312 //PROGRESS_INFO(function_name, i, nrl, nrh); 313 for(j=ncl; j<=nch; j++) { 314 315 //H[Si[j].r].r++; 316 //H[Si[j].g].g++; 317 //H[Si[j].b].b++; 318 319 r = S[i][j].r; 320 g = S[i][j].g; 321 b = S[i][j].b; 322 323 H[r].r++; 324 H[g].g++; 325 H[b].b++; 326 } 327 } 328 329 //END; 330 return; 331 } 205 206 207 for (int32_t i = nrl; i <= nrh; i++) { 208 Si = S[i]; 209 for (int32_t j = ncl; j <= nch; j++) { 210 r = S[i][j].r; 211 g = S[i][j].g; 212 b = S[i][j].b; 213 214 H[r].r++; 215 H[g].g++; 216 H[b].b++; 217 } 218 } 219 return; 220 } 221 222 // Local Variables: 223 // tab-width: 4 224 // c-basic-offset: 4 225 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 226 // indent-tabs-mode: nil 227 // End: 228 229 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 230
Note: See TracChangeset
for help on using the changeset viewer.