00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "flgrCoreData.h"
00022 #include "flgrCoreIO.h"
00023 #include "flgrCoreCopy.h"
00024 #include "flgrCoreDispatch.h"
00025 #include "flgrCoreChannel.h"
00026
00036
00037
00038 #define FLGR_MACRO_EXTRACT1D_CHANNEL(dtype) \
00039 dtype val; \
00040 dtype *psrc = (dtype *) datsrc->array; \
00041 dtype *pdest = (dtype *) datdest->array; \
00042 int k,i; \
00043 int spp = datsrc->spp; \
00044 \
00045 \
00046 \
00047 for(k=channel,i=0 ; i<datsrc->length ; i++,k+=spp) { \
00048 val = flgr_get_array_##dtype(psrc,k); \
00049 flgr_set_array_##dtype(pdest,i,val); \
00050 } \
00051 \
00052 return \
00053
00054
00055 void flgr1d_extract_channel_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00056 FLGR_MACRO_EXTRACT1D_CHANNEL(fgBIT);
00057 }
00058 void flgr1d_extract_channel_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00059 FLGR_MACRO_EXTRACT1D_CHANNEL(fgUINT8);
00060 }
00061 void flgr1d_extract_channel_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00062 FLGR_MACRO_EXTRACT1D_CHANNEL(fgUINT16);
00063 }
00064 void flgr1d_extract_channel_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00065 FLGR_MACRO_EXTRACT1D_CHANNEL(fgUINT32);
00066 }
00067 void flgr1d_extract_channel_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00068 FLGR_MACRO_EXTRACT1D_CHANNEL(fgINT8);
00069 }
00070 void flgr1d_extract_channel_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00071 FLGR_MACRO_EXTRACT1D_CHANNEL(fgINT16);
00072 }
00073 void flgr1d_extract_channel_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00074 FLGR_MACRO_EXTRACT1D_CHANNEL(fgINT32);
00075 }
00076 void flgr1d_extract_channel_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00077 FLGR_MACRO_EXTRACT1D_CHANNEL(fgFLOAT32);
00078 }
00079 void flgr1d_extract_channel_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00080 FLGR_MACRO_EXTRACT1D_CHANNEL(fgFLOAT64);
00081 }
00083
00089
00090 FLGR_Ret flgr1d_extract_channel(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00091 FLGR_Ret ret;
00092
00093
00094
00095 if((datdest==NULL) || (datsrc==NULL)) {
00096 POST_ERROR("Null object\n");
00097 return FLGR_RET_NULL_OBJECT;
00098 }
00099
00100 if(datdest->spp != 1) {
00101 POST_ERROR("Destination spp != 1\n");
00102 return FLGR_RET_UNDEFINED_ERROR;
00103 }
00104
00105 if((channel >= datsrc->spp) || (channel<0)) {
00106 POST_ERROR("Channel index not valid\n");
00107 return FLGR_RET_UNDEFINED_ERROR;
00108 }
00109
00110 if((ret = flgr1d_is_data_same_length(datdest,datsrc)) != FLGR_RET_OK) return ret;
00111 if((ret = flgr1d_is_data_same_type(datdest,datsrc)) != FLGR_RET_OK) return ret;
00112
00113
00114 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr1d_extract_channel, datdest,datsrc,channel);
00115
00116 }
00117
00118
00119
00120
00121
00124 #define FLGR_MACRO_COMPOSE1D_CHANNEL(dtype) \
00125 dtype val; \
00126 dtype *psrc = (dtype *) datsrc->array; \
00127 dtype *pdest = (dtype *) datdest->array; \
00128 int k,i; \
00129 int spp = datdest->spp; \
00130 \
00131 \
00132 \
00133 for(k=channel,i=0 ; i<datsrc->length ; i++,k+=spp) { \
00134 val = flgr_get_array_##dtype(psrc,i); \
00135 flgr_set_array_##dtype(pdest,k,val); \
00136 } \
00137 \
00138 return \
00139
00140
00141 void flgr1d_compose_channel_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00142 FLGR_MACRO_COMPOSE1D_CHANNEL(fgBIT);
00143 }
00144 void flgr1d_compose_channel_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00145 FLGR_MACRO_COMPOSE1D_CHANNEL(fgUINT8);
00146 }
00147 void flgr1d_compose_channel_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00148 FLGR_MACRO_COMPOSE1D_CHANNEL(fgUINT16);
00149 }
00150 void flgr1d_compose_channel_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00151 FLGR_MACRO_COMPOSE1D_CHANNEL(fgUINT32);
00152 }
00153 void flgr1d_compose_channel_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00154 FLGR_MACRO_COMPOSE1D_CHANNEL(fgINT8);
00155 }
00156 void flgr1d_compose_channel_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00157 FLGR_MACRO_COMPOSE1D_CHANNEL(fgINT16);
00158 }
00159 void flgr1d_compose_channel_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00160 FLGR_MACRO_COMPOSE1D_CHANNEL(fgINT32);
00161 }
00162 void flgr1d_compose_channel_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00163 FLGR_MACRO_COMPOSE1D_CHANNEL(fgFLOAT32);
00164 }
00165 void flgr1d_compose_channel_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00166 FLGR_MACRO_COMPOSE1D_CHANNEL(fgFLOAT64);
00167 }
00169
00175
00176 FLGR_Ret flgr1d_compose_channel(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, int channel) {
00177 FLGR_Ret ret;
00178
00179
00180
00181 if((datdest==NULL) || (datsrc==NULL)) {
00182 POST_ERROR("Null object\n");
00183 return FLGR_RET_NULL_OBJECT;
00184 }
00185
00186 if(datsrc->spp != 1) {
00187 POST_ERROR("Source spp != 1\n");
00188 return FLGR_RET_UNDEFINED_ERROR;
00189 }
00190
00191 if((channel >= datdest->spp) || (channel<0)) {
00192 POST_ERROR("Channel index not valid\n");
00193 return FLGR_RET_UNDEFINED_ERROR;
00194 }
00195
00196 if((ret = flgr1d_is_data_same_length(datdest,datsrc)) != FLGR_RET_OK) return ret;
00197 if((ret = flgr1d_is_data_same_type(datdest,datsrc)) != FLGR_RET_OK) return ret;
00198
00199
00200 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr1d_compose_channel, datdest,datsrc,channel);
00201
00202 }
00203
00204
00206
00210
00211 FLGR_Ret flgr1d_pack_channel(FLGR_Data1D *dat) {
00212
00213
00214 if((dat==NULL)) {
00215 POST_ERROR("Null object\n");
00216 return FLGR_RET_NULL_OBJECT;
00217 }
00218
00219 dat->length *= dat->spp;
00220 dat->spp=1;
00221
00222 return FLGR_RET_OK;
00223 }
00224
00225
00226
00227
00228
00230
00235
00236 FLGR_Ret flgr1d_unpack_channel(FLGR_Data1D *dat, int factor) {
00237
00238
00239 if((dat==NULL)) {
00240 POST_ERROR("Null object\n");
00241 return FLGR_RET_NULL_OBJECT;
00242 }
00243
00244 if(dat->length%factor!=0) {
00245 POST_WARNING("Could not unpack image, factor is not a multiple of signal length");
00246 }
00247
00248 dat->length /= factor;
00249 dat->spp=factor;
00250
00251 return FLGR_RET_OK;
00252
00253 }
00254
00255
00256
00259 #define FLGR_MACRO_REVERT_CHANNEL_1D(dtype) \
00260 dtype val; \
00261 dtype *psrc = (dtype *) datsrc->array; \
00262 dtype *pdest = (dtype *) datdest->array; \
00263 int l,k,j; \
00264 int spp = datdest->spp; \
00265 int length = datdest->spp*datdest->length; \
00266 \
00267 \
00268 \
00269 for(j=0 ; j<length ; j+=spp) { \
00270 for(k=0,l=spp-1;k<spp;k++,l--) { \
00271 val = flgr_get_array_##dtype(psrc,j+k); \
00272 flgr_set_array_##dtype(pdest,j+l,val); \
00273 } \
00274 } \
00275 \
00276 return
00277
00278
00279 void flgr1d_revert_channel_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00280 FLGR_MACRO_REVERT_CHANNEL_1D(fgBIT);
00281 }
00282 void flgr1d_revert_channel_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00283 FLGR_MACRO_REVERT_CHANNEL_1D(fgUINT8);
00284 }
00285 void flgr1d_revert_channel_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00286 FLGR_MACRO_REVERT_CHANNEL_1D(fgUINT16);
00287 }
00288 void flgr1d_revert_channel_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00289 FLGR_MACRO_REVERT_CHANNEL_1D(fgUINT32);
00290 }
00291 void flgr1d_revert_channel_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00292 FLGR_MACRO_REVERT_CHANNEL_1D(fgINT8);
00293 }
00294 void flgr1d_revert_channel_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00295 FLGR_MACRO_REVERT_CHANNEL_1D(fgINT16);
00296 }
00297 void flgr1d_revert_channel_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00298 FLGR_MACRO_REVERT_CHANNEL_1D(fgINT32);
00299 }
00300 void flgr1d_revert_channel_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00301 FLGR_MACRO_REVERT_CHANNEL_1D(fgFLOAT32);
00302 }
00303 void flgr1d_revert_channel_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00304 FLGR_MACRO_REVERT_CHANNEL_1D(fgFLOAT64);
00305 }
00306
00307
00308
00310
00315
00316 FLGR_Ret flgr1d_revert_channel(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00317 FLGR_Ret ret;
00318
00319
00320
00321 if((datdest==NULL) || (datsrc==NULL)) {
00322 POST_ERROR("Null object\n");
00323 return FLGR_RET_NULL_OBJECT;
00324 }
00325
00326 if((ret = flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__)) != FLGR_RET_OK) return ret;
00327
00328
00329 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr1d_revert_channel, datdest,datsrc);
00330 }
00331
00332
00333
00334
00337 #define FLGR_MACRO_MEAN_CHANNEL_1D(dtype,dtype2) \
00338 dtype2 val; \
00339 dtype *psrc = (dtype *) datsrc->array; \
00340 dtype *pdest = (dtype *) datdest->array; \
00341 int l,k,j; \
00342 int spp = datsrc->spp; \
00343 int length = spp*datsrc->length; \
00344 \
00345 \
00346 \
00347 for(j=0,l=0 ; j<length ; j+=spp,l++) { \
00348 val = 0; \
00349 for(k=0 ; k<spp ; k++) { \
00350 val += flgr_get_array_##dtype(psrc,j+k); \
00351 } \
00352 \
00353 flgr_set_array_##dtype(pdest,l,(dtype) (val / ((dtype2)spp)) ); \
00354 } \
00355 \
00356 return
00357
00358
00359 void flgr1d_mean_channel_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00360 FLGR_MACRO_MEAN_CHANNEL_1D(fgBIT,fgUINT32);
00361 }
00362 void flgr1d_mean_channel_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00363 FLGR_MACRO_MEAN_CHANNEL_1D(fgUINT8,fgUINT32);
00364 }
00365 void flgr1d_mean_channel_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00366 FLGR_MACRO_MEAN_CHANNEL_1D(fgUINT16,fgUINT32);
00367 }
00368 void flgr1d_mean_channel_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00369 FLGR_MACRO_MEAN_CHANNEL_1D(fgUINT32,fgUINT64);
00370 }
00371 void flgr1d_mean_channel_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00372 FLGR_MACRO_MEAN_CHANNEL_1D(fgINT8,fgINT32);
00373 }
00374 void flgr1d_mean_channel_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00375 FLGR_MACRO_MEAN_CHANNEL_1D(fgINT16,fgINT32);
00376 }
00377 void flgr1d_mean_channel_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00378 FLGR_MACRO_MEAN_CHANNEL_1D(fgINT32,fgINT64);
00379 }
00380 void flgr1d_mean_channel_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00381 FLGR_MACRO_MEAN_CHANNEL_1D(fgFLOAT32,fgFLOAT32);
00382 }
00383 void flgr1d_mean_channel_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00384 FLGR_MACRO_MEAN_CHANNEL_1D(fgFLOAT64,fgFLOAT32);
00385 }
00386
00387
00388
00390
00395
00396 FLGR_Ret flgr1d_mean_channel(FLGR_Data1D *datdest, FLGR_Data1D *datsrc) {
00397 FLGR_Ret ret;
00398
00399
00400
00401 if((datdest==NULL) || (datsrc==NULL)) {
00402 POST_ERROR("Null object\n");
00403 return FLGR_RET_NULL_OBJECT;
00404 }
00405
00406 if(datdest->spp != 1) {
00407 POST_ERROR("Destination spp != 1\n");
00408 return FLGR_RET_UNDEFINED_ERROR;
00409 }
00410
00411 if((ret = flgr1d_is_data_same_type(datdest,datsrc)) != FLGR_RET_OK) return ret;
00412 if((ret = flgr1d_is_data_same_length(datdest,datsrc)) != FLGR_RET_OK) return ret;
00413
00414
00415 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr1d_mean_channel, datdest,datsrc);
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00431 #define FLGR_MACRO_EXTRACT2D_CHANNEL(dtype) \
00432 FLGR_Data1D **psrc = datsrc->row; \
00433 FLGR_Data1D **pdest = datdest->row; \
00434 int i; \
00435 \
00436 \
00437 \
00438 for(i=0 ; i<datsrc->size_y ; i++,pdest++,psrc++) { \
00439 flgr1d_extract_channel_##dtype(*pdest,*psrc,channel); \
00440 } \
00441 \
00442 return \
00443
00444
00445 void flgr2d_extract_channel_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00446 FLGR_MACRO_EXTRACT2D_CHANNEL(fgBIT);
00447 }
00448 void flgr2d_extract_channel_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00449 FLGR_MACRO_EXTRACT2D_CHANNEL(fgUINT8);
00450 }
00451 void flgr2d_extract_channel_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00452 FLGR_MACRO_EXTRACT2D_CHANNEL(fgUINT16);
00453 }
00454 void flgr2d_extract_channel_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00455 FLGR_MACRO_EXTRACT2D_CHANNEL(fgUINT32);
00456 }
00457 void flgr2d_extract_channel_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00458 FLGR_MACRO_EXTRACT2D_CHANNEL(fgINT8);
00459 }
00460 void flgr2d_extract_channel_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00461 FLGR_MACRO_EXTRACT2D_CHANNEL(fgINT16);
00462 }
00463 void flgr2d_extract_channel_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00464 FLGR_MACRO_EXTRACT2D_CHANNEL(fgINT32);
00465 }
00466 void flgr2d_extract_channel_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00467 FLGR_MACRO_EXTRACT2D_CHANNEL(fgFLOAT32);
00468 }
00469 void flgr2d_extract_channel_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00470 FLGR_MACRO_EXTRACT2D_CHANNEL(fgFLOAT64);
00471 }
00473
00479
00480 FLGR_Ret flgr2d_extract_channel(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00481 FLGR_Ret ret;
00482
00483
00484
00485
00486 if((datdest==NULL) || (datsrc==NULL)) {
00487 POST_ERROR("Null object\n");
00488 return FLGR_RET_NULL_OBJECT;
00489 }
00490
00491 if(datdest->spp != 1) {
00492 POST_ERROR("Destination spp != 1\n");
00493 return FLGR_RET_UNDEFINED_ERROR;
00494 }
00495
00496 if((channel >= datsrc->spp) || (channel<0)) {
00497 POST_ERROR("Channel index not valid\n");
00498 return FLGR_RET_UNDEFINED_ERROR;
00499 }
00500
00501 if((ret = flgr2d_is_data_same_size(datdest,datsrc)) != FLGR_RET_OK) return ret;
00502 if((ret = flgr2d_is_data_same_type(datdest,datsrc)) != FLGR_RET_OK) return ret;
00503
00504
00505 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr2d_extract_channel, datdest,datsrc,channel);
00506
00507 }
00508
00509
00510
00511
00512
00515 #define FLGR_MACRO_COMPOSE2D_CHANNEL(dtype) \
00516 FLGR_Data1D **psrc = datsrc->row; \
00517 FLGR_Data1D **pdest = datdest->row; \
00518 int i; \
00519 \
00520 \
00521 \
00522 for(i=0 ; i<datsrc->size_y ; i++,pdest++,psrc++) { \
00523 flgr1d_compose_channel_##dtype(*pdest,*psrc,channel); \
00524 } \
00525 \
00526 return \
00527
00528
00529 void flgr2d_compose_channel_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00530 FLGR_MACRO_COMPOSE2D_CHANNEL(fgBIT);
00531 }
00532 void flgr2d_compose_channel_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00533 FLGR_MACRO_COMPOSE2D_CHANNEL(fgUINT8);
00534 }
00535 void flgr2d_compose_channel_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00536 FLGR_MACRO_COMPOSE2D_CHANNEL(fgUINT16);
00537 }
00538 void flgr2d_compose_channel_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00539 FLGR_MACRO_COMPOSE2D_CHANNEL(fgUINT32);
00540 }
00541 void flgr2d_compose_channel_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00542 FLGR_MACRO_COMPOSE2D_CHANNEL(fgINT8);
00543 }
00544 void flgr2d_compose_channel_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00545 FLGR_MACRO_COMPOSE2D_CHANNEL(fgINT16);
00546 }
00547 void flgr2d_compose_channel_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00548 FLGR_MACRO_COMPOSE2D_CHANNEL(fgINT32);
00549 }
00550 void flgr2d_compose_channel_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00551 FLGR_MACRO_COMPOSE2D_CHANNEL(fgFLOAT32);
00552 }
00553 void flgr2d_compose_channel_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00554 FLGR_MACRO_COMPOSE2D_CHANNEL(fgFLOAT64);
00555 }
00557
00563
00564 FLGR_Ret flgr2d_compose_channel(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, int channel) {
00565 FLGR_Ret ret;
00566
00567
00568
00569 if((datdest==NULL) || (datsrc==NULL)) {
00570 POST_ERROR("Null object\n");
00571 return FLGR_RET_NULL_OBJECT;
00572 }
00573
00574 if(datsrc->spp != 1) {
00575 POST_ERROR("Source spp != 1\n");
00576 return FLGR_RET_UNDEFINED_ERROR;
00577 }
00578
00579 if((channel >= datdest->spp) || (channel<0)) {
00580 POST_ERROR("Channel index not valid\n");
00581 return FLGR_RET_UNDEFINED_ERROR;
00582 }
00583
00584 if((ret = flgr2d_is_data_same_size(datdest,datsrc)) != FLGR_RET_OK) return ret;
00585 if((ret = flgr2d_is_data_same_type(datdest,datsrc)) != FLGR_RET_OK) return ret;
00586
00587
00588 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr2d_compose_channel, datdest,datsrc,channel);
00589
00590 }
00591
00592
00593
00594
00595
00596
00597
00599
00603
00604 FLGR_Ret flgr2d_pack_channel(FLGR_Data2D *dat) {
00605 FLGR_Data1D **pdat;
00606 int i;
00607
00608
00609
00610 if((dat==NULL)) {
00611 POST_ERROR("Null object\n");
00612 return FLGR_RET_NULL_OBJECT;
00613 }
00614
00615 dat->size_x *= dat->spp;
00616 dat->spp=1;
00617
00618 for(i=0,pdat = dat->row ; i<dat->size_y ; i++, pdat++) {
00619 flgr1d_pack_channel(*pdat);
00620 }
00621
00622 return FLGR_RET_OK;
00623 }
00624
00625
00626
00627
00628
00630
00635
00636 FLGR_Ret flgr2d_unpack_channel(FLGR_Data2D *dat, int factor) {
00637 FLGR_Data1D **pdat;
00638 int i;
00639
00640
00641
00642 if((dat==NULL)) {
00643 POST_ERROR("Null object\n");
00644 return FLGR_RET_NULL_OBJECT;
00645 }
00646
00647 if(dat->size_x%factor!=0) {
00648 POST_WARNING("Could not unpack image, factor is not a multiple of signal length");
00649 }
00650
00651 dat->size_x /= factor;
00652 dat->spp=factor;
00653
00654 for(i=0,pdat = dat->row ; i<dat->size_y ; i++, pdat++) {
00655 flgr1d_unpack_channel(*pdat, factor);
00656 }
00657
00658 return FLGR_RET_OK;
00659
00660 }
00661
00662
00663
00666 #define FLGR_MACRO_REVERT_CHANNEL_2D(dtype) \
00667 FLGR_Data1D **psrc = datsrc->row; \
00668 FLGR_Data1D **pdest = datdest->row; \
00669 int i; \
00670 \
00671 \
00672 \
00673 for(i=0 ; i<datsrc->size_y ; i++,pdest++,psrc++) { \
00674 flgr1d_revert_channel_##dtype(*pdest,*psrc); \
00675 } \
00676 \
00677 return \
00678
00679
00680 void flgr2d_revert_channel_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00681 FLGR_MACRO_REVERT_CHANNEL_2D(fgBIT);
00682 }
00683 void flgr2d_revert_channel_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00684 FLGR_MACRO_REVERT_CHANNEL_2D(fgUINT8);
00685 }
00686 void flgr2d_revert_channel_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00687 FLGR_MACRO_REVERT_CHANNEL_2D(fgUINT16);
00688 }
00689 void flgr2d_revert_channel_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00690 FLGR_MACRO_REVERT_CHANNEL_2D(fgUINT32);
00691 }
00692 void flgr2d_revert_channel_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00693 FLGR_MACRO_REVERT_CHANNEL_2D(fgINT8);
00694 }
00695 void flgr2d_revert_channel_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00696 FLGR_MACRO_REVERT_CHANNEL_2D(fgINT16);
00697 }
00698 void flgr2d_revert_channel_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00699 FLGR_MACRO_REVERT_CHANNEL_2D(fgINT32);
00700 }
00701 void flgr2d_revert_channel_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00702 FLGR_MACRO_REVERT_CHANNEL_2D(fgFLOAT32);
00703 }
00704 void flgr2d_revert_channel_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00705 FLGR_MACRO_REVERT_CHANNEL_2D(fgFLOAT64);
00706 }
00708
00713
00714 FLGR_Ret flgr2d_revert_channel(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00715 FLGR_Ret ret;
00716
00717
00718
00719 if((datdest==NULL) || (datsrc==NULL)) {
00720 POST_ERROR("Null object\n");
00721 return FLGR_RET_NULL_OBJECT;
00722 }
00723
00724 if((ret = flgr2d_is_data_same_attributes(datdest,datsrc,__FUNCTION__)) != FLGR_RET_OK) return ret;
00725
00726 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr2d_revert_channel, datdest,datsrc);
00727
00728 }
00729
00730
00733 #define FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(dtype) \
00734 FLGR_Data1D **psrc = dat->row; \
00735 FLGR_Data1D **pdest = dat->row; \
00736 FLGR_Data1D *ptmp = flgr1d_create_signal_from(*psrc); \
00737 int i; \
00738 \
00739 \
00740 \
00741 for(i=0 ; i<dat->size_y ; i++,pdest++,psrc++) { \
00742 flgr1d_revert_channel_##dtype(ptmp,*psrc); \
00743 flgr1d_copy_##dtype##_##dtype(*pdest,ptmp); \
00744 } \
00745 \
00746 flgr1d_destroy(ptmp); \
00747 return \
00748
00749
00750 void flgr2d_revert_channel_hmorph_fgBIT(FLGR_Data2D *dat) {
00751 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgBIT);
00752 }
00753 void flgr2d_revert_channel_hmorph_fgUINT8(FLGR_Data2D *dat) {
00754 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgUINT8);
00755 }
00756 void flgr2d_revert_channel_hmorph_fgUINT16(FLGR_Data2D *dat) {
00757 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgUINT16);
00758 }
00759 void flgr2d_revert_channel_hmorph_fgUINT32(FLGR_Data2D *dat) {
00760 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgUINT32);
00761 }
00762 void flgr2d_revert_channel_hmorph_fgINT8(FLGR_Data2D *dat) {
00763 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgINT8);
00764 }
00765 void flgr2d_revert_channel_hmorph_fgINT16(FLGR_Data2D *dat) {
00766 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgINT16);
00767 }
00768 void flgr2d_revert_channel_hmorph_fgINT32(FLGR_Data2D *dat) {
00769 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgINT32);
00770 }
00771 void flgr2d_revert_channel_hmorph_fgFLOAT32(FLGR_Data2D *dat) {
00772 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgFLOAT32);
00773 }
00774 void flgr2d_revert_channel_hmorph_fgFLOAT64(FLGR_Data2D *dat) {
00775 FLGR_MACRO_REVERT_CHANNEL_HMORPH_2D(fgFLOAT64);
00776 }
00778
00782
00783 FLGR_Ret flgr2d_revert_channel_hmorph(FLGR_Data2D *dat) {
00784
00785
00786 if(dat==NULL) {
00787 POST_ERROR("Null object\n");
00788 return FLGR_RET_NULL_OBJECT;
00789 }
00790
00791 FLGR_DISPATCH_PROCEDURE(dat->type, flgr2d_revert_channel_hmorph, dat);
00792
00793 }
00794
00795
00796
00797
00798
00801 #define FLGR_MACRO_MEAN_CHANNEL_2D(dtype) \
00802 FLGR_Data1D **psrc = datsrc->row; \
00803 FLGR_Data1D **pdest = datdest->row; \
00804 int i; \
00805 \
00806 \
00807 \
00808 for(i=0 ; i<datsrc->size_y ; i++,pdest++,psrc++) { \
00809 flgr1d_mean_channel_##dtype(*pdest,*psrc); \
00810 } \
00811 \
00812 return
00813
00814
00815 void flgr2d_mean_channel_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00816 FLGR_MACRO_MEAN_CHANNEL_2D(fgBIT);
00817 }
00818 void flgr2d_mean_channel_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00819 FLGR_MACRO_MEAN_CHANNEL_2D(fgUINT8);
00820 }
00821 void flgr2d_mean_channel_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00822 FLGR_MACRO_MEAN_CHANNEL_2D(fgUINT16);
00823 }
00824 void flgr2d_mean_channel_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00825 FLGR_MACRO_MEAN_CHANNEL_2D(fgUINT32);
00826 }
00827 void flgr2d_mean_channel_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00828 FLGR_MACRO_MEAN_CHANNEL_2D(fgINT8);
00829 }
00830 void flgr2d_mean_channel_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00831 FLGR_MACRO_MEAN_CHANNEL_2D(fgINT16);
00832 }
00833 void flgr2d_mean_channel_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00834 FLGR_MACRO_MEAN_CHANNEL_2D(fgINT32);
00835 }
00836 void flgr2d_mean_channel_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00837 FLGR_MACRO_MEAN_CHANNEL_2D(fgFLOAT32);
00838 }
00839 void flgr2d_mean_channel_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00840 FLGR_MACRO_MEAN_CHANNEL_2D(fgFLOAT64);
00841 }
00842
00843
00844
00846
00851
00852 FLGR_Ret flgr2d_mean_channel(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00853 FLGR_Ret ret;
00854
00855
00856
00857 if((datdest==NULL) || (datsrc==NULL)) {
00858 POST_ERROR("Null object\n");
00859 return FLGR_RET_NULL_OBJECT;
00860 }
00861
00862 if(datdest->spp != 1) {
00863 POST_ERROR("Destination spp != 1\n");
00864 return FLGR_RET_UNDEFINED_ERROR;
00865 }
00866
00867 if((ret = flgr2d_is_data_same_type(datdest,datsrc)) != FLGR_RET_OK) return ret;
00868 if((ret = flgr2d_is_data_same_size(datdest,datsrc)) != FLGR_RET_OK) return ret;
00869
00870
00871 FLGR_DISPATCH_PROCEDURE(datdest->type, flgr2d_mean_channel, datdest,datsrc);
00872 }
00874