00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <flgrCoreIO.h>
00026 #include <flgrCoreData.h>
00027 #include <flgrCoreDataIO.h>
00028 #include <flgrCoreDispatch.h>
00029 #include "flgrMorphoDistanceFast.h"
00030
00031
00034 #define FLGR_MACRO_FAST_RASTER_DISTANCE_8(dtype) \
00035 int i,j; \
00036 int k,l,n; \
00037 int sx = dat->size_x; \
00038 int sy = dat->size_y; \
00039 dtype **pdat=(dtype **) dat->array; \
00040 dtype minval; \
00041 dtype valpix; \
00042 \
00043 \
00044 minval = flgr2d_get_data_array_##dtype(pdat,0,0); \
00045 \
00046 \
00047 for(j=1 ; j<sx-1 ; j++) { \
00048 valpix = flgr2d_get_data_array_##dtype(pdat,0,j); \
00049 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00050 flgr2d_set_data_array_##dtype(pdat,0,j,minval); \
00051 } \
00052 \
00053 \
00054 for(i=1,k=0 ; i<sy ; i++,k++) { \
00055 \
00056 minval = flgr2d_get_data_array_##dtype(pdat,k,0); \
00057 valpix = flgr2d_get_data_array_##dtype(pdat,k,1); \
00058 minval = FLGR_MIN(valpix,minval); \
00059 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00060 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00061 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00062 \
00063 \
00064 for(l=0,j=1,n=2 ; j<sx-1 ; j++,l++,n++) { \
00065 valpix = flgr2d_get_data_array_##dtype(pdat,k,l); \
00066 minval = FLGR_MIN(valpix,minval); \
00067 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00068 minval = FLGR_MIN(valpix,minval); \
00069 valpix = flgr2d_get_data_array_##dtype(pdat,k,n); \
00070 minval = FLGR_MIN(valpix,minval); \
00071 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00072 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00073 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00074 } \
00075 \
00076 \
00077 valpix = flgr2d_get_data_array_##dtype(pdat,k,sx-1); \
00078 minval = FLGR_MIN(valpix,minval); \
00079 valpix = flgr2d_get_data_array_##dtype(pdat,k,sx-2); \
00080 minval = FLGR_MIN(valpix,minval); \
00081 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00082 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00083 flgr2d_set_data_array_##dtype(pdat,i,sx-1,minval); \
00084 \
00085 \
00086 } \
00087 \
00088 return
00089
00090 void flgr2d_distance_raster_8_connexity_fgUINT8(FLGR_Data2D *dat) {
00091 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgUINT8);
00092 }
00093 void flgr2d_distance_raster_8_connexity_fgUINT16(FLGR_Data2D *dat) {
00094 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgUINT16);
00095 }
00096 void flgr2d_distance_raster_8_connexity_fgUINT32(FLGR_Data2D *dat) {
00097 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgUINT32);
00098 }
00099 void flgr2d_distance_raster_8_connexity_fgINT8(FLGR_Data2D *dat) {
00100 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgINT8);
00101 }
00102 void flgr2d_distance_raster_8_connexity_fgINT16(FLGR_Data2D *dat) {
00103 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgINT16);
00104 }
00105 void flgr2d_distance_raster_8_connexity_fgINT32(FLGR_Data2D *dat) {
00106 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgINT32);
00107 }
00108 void flgr2d_distance_raster_8_connexity_fgFLOAT32(FLGR_Data2D *dat) {
00109 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgFLOAT32);
00110 }
00111 void flgr2d_distance_raster_8_connexity_fgFLOAT64(FLGR_Data2D *dat) {
00112 FLGR_MACRO_FAST_RASTER_DISTANCE_8(fgFLOAT64);
00113 }
00114
00115
00116
00117
00120 #define FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(dtype) \
00121 int i,j; \
00122 int k,l,n; \
00123 int sx = dat->size_x; \
00124 int sy = dat->size_y; \
00125 dtype **pdat=(dtype **) dat->array; \
00126 dtype minval; \
00127 dtype valpix; \
00128 \
00129 \
00130 minval = flgr2d_get_data_array_##dtype(pdat,sy-1,sx-1); \
00131 \
00132 \
00133 for(j=sx-2 ; j>=0 ; j--) { \
00134 valpix = flgr2d_get_data_array_##dtype(pdat,sy-1,j); \
00135 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00136 flgr2d_set_data_array_##dtype(pdat,sy-1,j,minval); \
00137 } \
00138 \
00139 \
00140 for(i=sy-2,k=sy-1 ; i>=0 ; i--,k--) { \
00141 \
00142 minval = flgr2d_get_data_array_##dtype(pdat,k,sx-1); \
00143 valpix = flgr2d_get_data_array_##dtype(pdat,k,sx-2); \
00144 minval = FLGR_MIN(valpix,minval); \
00145 valpix = flgr2d_get_data_array_##dtype(pdat,i,sx-1); \
00146 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00147 flgr2d_set_data_array_##dtype(pdat,i,sx-1,minval); \
00148 \
00149 \
00150 for(l=sx-3,j=sx-2,n=sx-1 ; j>=1 ; j--,l--,n--) { \
00151 valpix = flgr2d_get_data_array_##dtype(pdat,k,l); \
00152 minval = FLGR_MIN(valpix,minval); \
00153 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00154 minval = FLGR_MIN(valpix,minval); \
00155 valpix = flgr2d_get_data_array_##dtype(pdat,k,n); \
00156 minval = FLGR_MIN(valpix,minval); \
00157 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00158 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00159 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00160 } \
00161 \
00162 \
00163 valpix = flgr2d_get_data_array_##dtype(pdat,k,0); \
00164 minval = FLGR_MIN(valpix,minval); \
00165 valpix = flgr2d_get_data_array_##dtype(pdat,k,1); \
00166 minval = FLGR_MIN(valpix,minval); \
00167 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00168 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00169 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00170 \
00171 \
00172 } \
00173 \
00174 return
00175
00176
00177 void flgr2d_distance_antiraster_8_connexity_fgUINT8(FLGR_Data2D *dat) {
00178 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgUINT8);
00179 }
00180 void flgr2d_distance_antiraster_8_connexity_fgUINT16(FLGR_Data2D *dat) {
00181 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgUINT16);
00182 }
00183 void flgr2d_distance_antiraster_8_connexity_fgUINT32(FLGR_Data2D *dat) {
00184 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgUINT32);
00185 }
00186 void flgr2d_distance_antiraster_8_connexity_fgINT8(FLGR_Data2D *dat) {
00187 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgINT8);
00188 }
00189 void flgr2d_distance_antiraster_8_connexity_fgINT16(FLGR_Data2D *dat) {
00190 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgINT16);
00191 }
00192 void flgr2d_distance_antiraster_8_connexity_fgINT32(FLGR_Data2D *dat) {
00193 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgINT32);
00194 }
00195 void flgr2d_distance_antiraster_8_connexity_fgFLOAT32(FLGR_Data2D *dat) {
00196 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgFLOAT32);
00197 }
00198 void flgr2d_distance_antiraster_8_connexity_fgFLOAT64(FLGR_Data2D *dat) {
00199 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_8(fgFLOAT64);
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00217 #define FLGR_MACRO_FAST_RASTER_DISTANCE_6(dtype) \
00218 int i,j; \
00219 int k,l,n; \
00220 int sx = dat->size_x; \
00221 int sy = dat->size_y; \
00222 dtype **pdat=(dtype **) dat->array; \
00223 dtype minval; \
00224 dtype valpix; \
00225 \
00226 \
00227 minval = flgr2d_get_data_array_##dtype(pdat,0,0); \
00228 \
00229 \
00230 for(j=1 ; j<sx-1 ; j++) { \
00231 valpix = flgr2d_get_data_array_##dtype(pdat,0,j); \
00232 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00233 flgr2d_set_data_array_##dtype(pdat,0,j,minval); \
00234 } \
00235 \
00236 \
00237 for(i=1,k=0 ; i<sy-1 ; i+=2,k+=2) { \
00238 \
00239 \
00240 \
00241 \
00242 minval = flgr2d_get_data_array_##dtype(pdat,k,0); \
00243 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00244 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00245 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00246 \
00247 \
00248 for(l=0,j=1 ; j<sx ; j++,l++) { \
00249 valpix = flgr2d_get_data_array_##dtype(pdat,k,l); \
00250 minval = FLGR_MIN(valpix,minval); \
00251 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00252 minval = FLGR_MIN(valpix,minval); \
00253 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00254 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00255 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00256 } \
00257 \
00258 \
00259 \
00260 \
00261 minval = flgr2d_get_data_array_##dtype(pdat,i,0); \
00262 valpix = flgr2d_get_data_array_##dtype(pdat,i,1); \
00263 minval = FLGR_MIN(valpix,minval); \
00264 valpix = flgr2d_get_data_array_##dtype(pdat,i+1,0); \
00265 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00266 flgr2d_set_data_array_##dtype(pdat,i+1,0,minval); \
00267 \
00268 \
00269 for(j=1,n=2 ; j<sx-1 ; j++,n++) { \
00270 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00271 minval = FLGR_MIN(valpix,minval); \
00272 valpix = flgr2d_get_data_array_##dtype(pdat,i,n); \
00273 minval = FLGR_MIN(valpix,minval); \
00274 valpix = flgr2d_get_data_array_##dtype(pdat,i+1,j); \
00275 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00276 flgr2d_set_data_array_##dtype(pdat,i+1,j,minval); \
00277 } \
00278 \
00279 \
00280 valpix = flgr2d_get_data_array_##dtype(pdat,i,sx-1); \
00281 minval = FLGR_MIN(valpix,minval); \
00282 valpix = flgr2d_get_data_array_##dtype(pdat,i+1,j); \
00283 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00284 flgr2d_set_data_array_##dtype(pdat,i+1,sx-1,minval); \
00285 \
00286 } \
00287 \
00288 if((sy%2)==0) { \
00289 \
00290 \
00291 \
00292 i = sy-1; \
00293 k = sy-2; \
00294 \
00295 minval = flgr2d_get_data_array_##dtype(pdat,k,0); \
00296 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00297 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00298 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00299 \
00300 \
00301 for(l=0,j=1 ; j<sx ; j++,l++) { \
00302 valpix = flgr2d_get_data_array_##dtype(pdat,k,l); \
00303 minval = FLGR_MIN(valpix,minval); \
00304 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00305 minval = FLGR_MIN(valpix,minval); \
00306 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00307 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00308 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00309 } \
00310 \
00311 } \
00312 \
00313 return
00314
00315 void flgr2d_distance_raster_6_connexity_fgUINT8(FLGR_Data2D *dat) {
00316 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgUINT8);
00317 }
00318 void flgr2d_distance_raster_6_connexity_fgUINT16(FLGR_Data2D *dat) {
00319 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgUINT16);
00320 }
00321 void flgr2d_distance_raster_6_connexity_fgUINT32(FLGR_Data2D *dat) {
00322 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgUINT32);
00323 }
00324 void flgr2d_distance_raster_6_connexity_fgINT8(FLGR_Data2D *dat) {
00325 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgINT8);
00326 }
00327 void flgr2d_distance_raster_6_connexity_fgINT16(FLGR_Data2D *dat) {
00328 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgINT16);
00329 }
00330 void flgr2d_distance_raster_6_connexity_fgINT32(FLGR_Data2D *dat) {
00331 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgINT32);
00332 }
00333 void flgr2d_distance_raster_6_connexity_fgFLOAT32(FLGR_Data2D *dat) {
00334 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgFLOAT32);
00335 }
00336 void flgr2d_distance_raster_6_connexity_fgFLOAT64(FLGR_Data2D *dat) {
00337 FLGR_MACRO_FAST_RASTER_DISTANCE_6(fgFLOAT64);
00338 }
00339
00340
00341
00342
00344
00346 #define FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(dtype) \
00347 int i,j; \
00348 int k,l,n; \
00349 int istart; \
00350 int sx = dat->size_x; \
00351 int sy = dat->size_y; \
00352 dtype **pdat=(dtype **) dat->array; \
00353 dtype minval; \
00354 dtype valpix; \
00355 \
00356 \
00357 minval = flgr2d_get_data_array_##dtype(pdat,sy-1,sx-1); \
00358 \
00359 \
00360 if((sy%2)==0) { \
00361 \
00362 \
00363 \
00364 i = sy-1; \
00365 \
00366 for(j=sx-2 ; j>=0 ; j--) { \
00367 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00368 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00369 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00370 } \
00371 \
00372 \
00373 \
00374 \
00375 k = i--; \
00376 \
00377 minval = flgr2d_get_data_array_##dtype(pdat,k,sx-1); \
00378 valpix = flgr2d_get_data_array_##dtype(pdat,i,sx-1); \
00379 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00380 flgr2d_set_data_array_##dtype(pdat,i,sx-1,minval); \
00381 \
00382 for(l=sx-1,j=sx-2 ; j>=0 ; j--,l--) { \
00383 valpix = flgr2d_get_data_array_##dtype(pdat,k,l); \
00384 minval = FLGR_MIN(valpix,minval); \
00385 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00386 minval = FLGR_MIN(valpix,minval); \
00387 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00388 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00389 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00390 } \
00391 \
00392 istart = sy-3; \
00393 \
00394 }else { \
00395 \
00396 \
00397 \
00398 i = sy-1; \
00399 \
00400 for(j=sx-2 ; j>=0 ; j--) { \
00401 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00402 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00403 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00404 } \
00405 \
00406 istart = sy-2; \
00407 \
00408 } \
00409 \
00410 for(i=istart,k=istart+1 ; i>=0 ; i-=2,k-=2) { \
00411 \
00412 \
00413 \
00414 \
00415 minval = flgr2d_get_data_array_##dtype(pdat,k,sx-1); \
00416 valpix = flgr2d_get_data_array_##dtype(pdat,k,sx-2); \
00417 minval = FLGR_MIN(valpix,minval); \
00418 valpix = flgr2d_get_data_array_##dtype(pdat,i,sx-1); \
00419 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00420 flgr2d_set_data_array_##dtype(pdat,i,sx-1,minval); \
00421 \
00422 \
00423 for(l=sx-3,j=sx-2 ; j>=1 ; j--,l--) { \
00424 valpix = flgr2d_get_data_array_##dtype(pdat,k,l); \
00425 minval = FLGR_MIN(valpix,minval); \
00426 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00427 minval = FLGR_MIN(valpix,minval); \
00428 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00429 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00430 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00431 } \
00432 \
00433 \
00434 valpix = flgr2d_get_data_array_##dtype(pdat,k,0); \
00435 minval = FLGR_MIN(valpix,minval); \
00436 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00437 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00438 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00439 \
00440 \
00441 \
00442 \
00443 \
00444 minval = flgr2d_get_data_array_##dtype(pdat,i,sx-1); \
00445 valpix = flgr2d_get_data_array_##dtype(pdat,i-1,sx-1); \
00446 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00447 flgr2d_set_data_array_##dtype(pdat,i-1,sx-1,minval); \
00448 \
00449 \
00450 for(j=sx-2,n=sx-1 ; j>=0 ; j--,n--) { \
00451 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00452 minval = FLGR_MIN(valpix,minval); \
00453 valpix = flgr2d_get_data_array_##dtype(pdat,i,n); \
00454 minval = FLGR_MIN(valpix,minval); \
00455 valpix = flgr2d_get_data_array_##dtype(pdat,i-1,j); \
00456 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00457 flgr2d_set_data_array_##dtype(pdat,i-1,j,minval); \
00458 } \
00459 \
00460 } \
00461 \
00462 return
00463
00464
00465 void flgr2d_distance_antiraster_6_connexity_fgUINT8(FLGR_Data2D *dat) {
00466 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgUINT8);
00467 }
00468 void flgr2d_distance_antiraster_6_connexity_fgUINT16(FLGR_Data2D *dat) {
00469 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgUINT16);
00470 }
00471 void flgr2d_distance_antiraster_6_connexity_fgUINT32(FLGR_Data2D *dat) {
00472 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgUINT32);
00473 }
00474 void flgr2d_distance_antiraster_6_connexity_fgINT8(FLGR_Data2D *dat) {
00475 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgINT8);
00476 }
00477 void flgr2d_distance_antiraster_6_connexity_fgINT16(FLGR_Data2D *dat) {
00478 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgINT16);
00479 }
00480 void flgr2d_distance_antiraster_6_connexity_fgINT32(FLGR_Data2D *dat) {
00481 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgINT32);
00482 }
00483 void flgr2d_distance_antiraster_6_connexity_fgFLOAT32(FLGR_Data2D *dat) {
00484 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgFLOAT32);
00485 }
00486 void flgr2d_distance_antiraster_6_connexity_fgFLOAT64(FLGR_Data2D *dat) {
00487 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_6(fgFLOAT64);
00488 }
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00511 #define FLGR_MACRO_FAST_RASTER_DISTANCE_4(dtype) \
00512 int i,j; \
00513 int k; \
00514 int sx = dat->size_x; \
00515 int sy = dat->size_y; \
00516 dtype **pdat=(dtype **) dat->array; \
00517 dtype minval; \
00518 dtype valpix; \
00519 \
00520 \
00521 minval = flgr2d_get_data_array_##dtype(pdat,0,0); \
00522 \
00523 \
00524 for(j=1 ; j<sx-1 ; j++) { \
00525 valpix = flgr2d_get_data_array_##dtype(pdat,0,j); \
00526 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00527 flgr2d_set_data_array_##dtype(pdat,0,j,minval); \
00528 } \
00529 \
00530 \
00531 for(i=1,k=0 ; i<sy ; i++,k++) { \
00532 \
00533 minval = flgr2d_get_data_array_##dtype(pdat,k,0); \
00534 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00535 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00536 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00537 \
00538 \
00539 for(j=1 ; j<sx-1 ; j++) { \
00540 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00541 minval = FLGR_MIN(valpix,minval); \
00542 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00543 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00544 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00545 } \
00546 \
00547 \
00548 valpix = flgr2d_get_data_array_##dtype(pdat,k,sx-1); \
00549 minval = FLGR_MIN(valpix,minval); \
00550 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00551 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00552 flgr2d_set_data_array_##dtype(pdat,i,sx-1,minval); \
00553 \
00554 \
00555 } \
00556 \
00557 return
00558
00559 void flgr2d_distance_raster_4_connexity_fgUINT8(FLGR_Data2D *dat) {
00560 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgUINT8);
00561 }
00562 void flgr2d_distance_raster_4_connexity_fgUINT16(FLGR_Data2D *dat) {
00563 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgUINT16);
00564 }
00565 void flgr2d_distance_raster_4_connexity_fgUINT32(FLGR_Data2D *dat) {
00566 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgUINT32);
00567 }
00568 void flgr2d_distance_raster_4_connexity_fgINT8(FLGR_Data2D *dat) {
00569 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgINT8);
00570 }
00571 void flgr2d_distance_raster_4_connexity_fgINT16(FLGR_Data2D *dat) {
00572 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgINT16);
00573 }
00574 void flgr2d_distance_raster_4_connexity_fgINT32(FLGR_Data2D *dat) {
00575 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgINT32);
00576 }
00577 void flgr2d_distance_raster_4_connexity_fgFLOAT32(FLGR_Data2D *dat) {
00578 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgFLOAT32);
00579 }
00580 void flgr2d_distance_raster_4_connexity_fgFLOAT64(FLGR_Data2D *dat) {
00581 FLGR_MACRO_FAST_RASTER_DISTANCE_4(fgFLOAT64);
00582 }
00583
00584
00585
00586
00589 #define FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(dtype) \
00590 int i,j; \
00591 int k; \
00592 int sx = dat->size_x; \
00593 int sy = dat->size_y; \
00594 dtype **pdat=(dtype **) dat->array; \
00595 dtype minval; \
00596 dtype valpix; \
00597 \
00598 \
00599 minval = flgr2d_get_data_array_##dtype(pdat,sy-1,sx-1); \
00600 \
00601 \
00602 for(j=sx-2 ; j>=0 ; j--) { \
00603 valpix = flgr2d_get_data_array_##dtype(pdat,sy-1,j); \
00604 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00605 flgr2d_set_data_array_##dtype(pdat,sy-1,j,minval); \
00606 } \
00607 \
00608 \
00609 for(i=sy-2,k=sy-1 ; i>=0 ; i--,k--) { \
00610 \
00611 minval = flgr2d_get_data_array_##dtype(pdat,k,sx-1); \
00612 valpix = flgr2d_get_data_array_##dtype(pdat,i,sx-1); \
00613 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00614 flgr2d_set_data_array_##dtype(pdat,i,sx-1,minval); \
00615 \
00616 \
00617 for(j=sx-2 ; j>=1 ; j--) { \
00618 valpix = flgr2d_get_data_array_##dtype(pdat,k,j); \
00619 minval = FLGR_MIN(valpix,minval); \
00620 valpix = flgr2d_get_data_array_##dtype(pdat,i,j); \
00621 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00622 flgr2d_set_data_array_##dtype(pdat,i,j,minval); \
00623 } \
00624 \
00625 \
00626 valpix = flgr2d_get_data_array_##dtype(pdat,k,0); \
00627 minval = FLGR_MIN(valpix,minval); \
00628 valpix = flgr2d_get_data_array_##dtype(pdat,i,0); \
00629 minval = (valpix == 0) ? 0 : (FLGR_MIN(minval+1,valpix)); \
00630 flgr2d_set_data_array_##dtype(pdat,i,0,minval); \
00631 \
00632 \
00633 } \
00634 \
00635 return
00636
00637
00638 void flgr2d_distance_antiraster_4_connexity_fgUINT8(FLGR_Data2D *dat) {
00639 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgUINT8);
00640 }
00641 void flgr2d_distance_antiraster_4_connexity_fgUINT16(FLGR_Data2D *dat) {
00642 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgUINT16);
00643 }
00644 void flgr2d_distance_antiraster_4_connexity_fgUINT32(FLGR_Data2D *dat) {
00645 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgUINT32);
00646 }
00647 void flgr2d_distance_antiraster_4_connexity_fgINT8(FLGR_Data2D *dat) {
00648 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgINT8);
00649 }
00650 void flgr2d_distance_antiraster_4_connexity_fgINT16(FLGR_Data2D *dat) {
00651 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgINT16);
00652 }
00653 void flgr2d_distance_antiraster_4_connexity_fgINT32(FLGR_Data2D *dat) {
00654 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgINT32);
00655 }
00656 void flgr2d_distance_antiraster_4_connexity_fgFLOAT32(FLGR_Data2D *dat) {
00657 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgFLOAT32);
00658 }
00659 void flgr2d_distance_antiraster_4_connexity_fgFLOAT64(FLGR_Data2D *dat) {
00660 FLGR_MACRO_FAST_ANTIRASTER_DISTANCE_4(fgFLOAT64);
00661 }
00662