diff options
Diffstat (limited to 'src/process')
-rw-r--r-- | src/process/im_arithmetic_bin.cpp | 17 | ||||
-rw-r--r-- | src/process/im_morphology_bin.cpp | 17 | ||||
-rw-r--r-- | src/process/im_morphology_gray.cpp | 26 |
3 files changed, 42 insertions, 18 deletions
diff --git a/src/process/im_arithmetic_bin.cpp b/src/process/im_arithmetic_bin.cpp index 575e650..a22e8cc 100644 --- a/src/process/im_arithmetic_bin.cpp +++ b/src/process/im_arithmetic_bin.cpp @@ -2,7 +2,7 @@ * \brief Binary Arithmetic Operations * * See Copyright Notice in im_lib.h - * $Id: im_arithmetic_bin.cpp,v 1.3 2010/01/08 03:49:05 scuri Exp $ + * $Id: im_arithmetic_bin.cpp,v 1.4 2011/04/05 02:35:10 scuri Exp $ */ @@ -580,6 +580,7 @@ void imProcessArithmeticConstOp(const imImage* src_image1, float value, imImage* void imProcessMultipleMean(const imImage** src_image_list, int src_image_count, imImage* dst_image) { const imImage* image1 = src_image_list[0]; + imImage* aux_image = NULL; int data_type = image1->data_type; if (image1->data_type == IM_BYTE) @@ -589,16 +590,26 @@ void imProcessMultipleMean(const imImage** src_image_list, int src_image_count, if (!acum_image) return; + if (image1->data_type == IM_BYTE) + aux_image = imImageCreate(image1->width, image1->height, image1->color_space, data_type); + for(int i = 0; i < src_image_count; i++) { const imImage *image = src_image_list[i]; - imProcessArithmeticOp(image, acum_image, acum_image, IM_BIN_ADD); /* acum_image += image */ - + if (aux_image) + { + imProcessUnArithmeticOp(image, aux_image, IM_UN_EQL); + imProcessArithmeticOp(aux_image, acum_image, acum_image, IM_BIN_ADD); /* acum_image += image */ + } + else + imProcessArithmeticOp(image, acum_image, acum_image, IM_BIN_ADD); /* acum_image += image */ } imProcessArithmeticConstOp(acum_image, float(src_image_count), dst_image, IM_BIN_DIV); imImageDestroy(acum_image); + if (aux_image) + imImageDestroy(aux_image); } void imProcessMultipleStdDev(const imImage** src_image_list, int src_image_count, const imImage *mean_image, imImage* dst_image) diff --git a/src/process/im_morphology_bin.cpp b/src/process/im_morphology_bin.cpp index 9405ff6..4429f7d 100644 --- a/src/process/im_morphology_bin.cpp +++ b/src/process/im_morphology_bin.cpp @@ -2,7 +2,7 @@ * \brief Morphology Operations for Binary Images * * See Copyright Notice in im_lib.h - * $Id: im_morphology_bin.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $ + * $Id: im_morphology_bin.cpp,v 1.2 2011/04/05 02:35:10 scuri Exp $ */ @@ -152,8 +152,10 @@ int imProcessBinMorphOpen(const imImage* src_image, imImage* dst_image, int kern if (!temp) return 0; - if (!imProcessBinMorphErode(src_image, temp, kernel_size, iter)) {imImageDestroy(temp); return 0;} - if (!imProcessBinMorphDilate(temp, dst_image, kernel_size, iter)) {imImageDestroy(temp); return 0;} + if (!imProcessBinMorphErode(src_image, temp, kernel_size, iter)) + {imImageDestroy(temp); return 0;} + if (!imProcessBinMorphDilate(temp, dst_image, kernel_size, iter)) + {imImageDestroy(temp); return 0;} imImageDestroy(temp); return 1; @@ -165,8 +167,10 @@ int imProcessBinMorphClose(const imImage* src_image, imImage* dst_image, int ker if (!temp) return 0; - if (!imProcessBinMorphDilate(src_image, temp, kernel_size, iter)) {imImageDestroy(temp); return 0;} - if (!imProcessBinMorphErode(temp, dst_image, kernel_size, iter)) {imImageDestroy(temp); return 0;} + if (!imProcessBinMorphDilate(src_image, temp, kernel_size, iter)) + {imImageDestroy(temp); return 0;} + if (!imProcessBinMorphErode(temp, dst_image, kernel_size, iter)) + {imImageDestroy(temp); return 0;} imImageDestroy(temp); return 1; @@ -174,7 +178,8 @@ int imProcessBinMorphClose(const imImage* src_image, imImage* dst_image, int ker int imProcessBinMorphOutline(const imImage* src_image, imImage* dst_image, int kernel_size, int iter) { - if (!imProcessBinMorphErode(src_image, dst_image, kernel_size, iter)) return 0; + if (!imProcessBinMorphErode(src_image, dst_image, kernel_size, iter)) + return 0; imProcessArithmeticOp(src_image, dst_image, dst_image, IM_BIN_DIFF); return 1; } diff --git a/src/process/im_morphology_gray.cpp b/src/process/im_morphology_gray.cpp index c3c9d45..d064932 100644 --- a/src/process/im_morphology_gray.cpp +++ b/src/process/im_morphology_gray.cpp @@ -2,7 +2,7 @@ * \brief Morphology Operations for Gray Images * * See Copyright Notice in im_lib.h - * $Id: im_morphology_gray.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $ + * $Id: im_morphology_gray.cpp,v 1.2 2011/04/05 02:35:10 scuri Exp $ */ @@ -180,8 +180,10 @@ int imProcessGrayMorphOpen(const imImage* src_image, imImage* dst_image, int ker if (!temp) return 0; - if (!imProcessGrayMorphErode(src_image, temp, kernel_size)) {imImageDestroy(temp); return 0;} - if (!imProcessGrayMorphDilate(temp, dst_image, kernel_size)) {imImageDestroy(temp); return 0;} + if (!imProcessGrayMorphErode(src_image, temp, kernel_size)) + {imImageDestroy(temp); return 0;} + if (!imProcessGrayMorphDilate(temp, dst_image, kernel_size)) + {imImageDestroy(temp); return 0;} imImageDestroy(temp); return 1; @@ -193,8 +195,10 @@ int imProcessGrayMorphClose(const imImage* src_image, imImage* dst_image, int ke if (!temp) return 0; - if (!imProcessGrayMorphDilate(src_image, temp, kernel_size)) {imImageDestroy(temp); return 0;} - if (!imProcessGrayMorphErode(temp, dst_image, kernel_size)) {imImageDestroy(temp); return 0;} + if (!imProcessGrayMorphDilate(src_image, temp, kernel_size)) + {imImageDestroy(temp); return 0;} + if (!imProcessGrayMorphErode(temp, dst_image, kernel_size)) + {imImageDestroy(temp); return 0;} imImageDestroy(temp); return 1; @@ -202,14 +206,16 @@ int imProcessGrayMorphClose(const imImage* src_image, imImage* dst_image, int ke int imProcessGrayMorphTopHat(const imImage* src_image, imImage* dst_image, int kernel_size) { - if (!imProcessGrayMorphOpen(src_image, dst_image, kernel_size)) return 0; + if (!imProcessGrayMorphOpen(src_image, dst_image, kernel_size)) + return 0; imProcessArithmeticOp(src_image, dst_image, dst_image, IM_BIN_DIFF); return 1; } int imProcessGrayMorphWell(const imImage* src_image, imImage* dst_image, int kernel_size) { - if (!imProcessGrayMorphClose(src_image, dst_image, kernel_size)) return 0; + if (!imProcessGrayMorphClose(src_image, dst_image, kernel_size)) + return 0; imProcessArithmeticOp(src_image, dst_image, dst_image, IM_BIN_DIFF); return 1; } @@ -220,8 +226,10 @@ int imProcessGrayMorphGradient(const imImage* src_image, imImage* dst_image, int if (!temp) return 0; - if (!imProcessGrayMorphDilate(src_image, temp, kernel_size)) {imImageDestroy(temp); return 0;} - if (!imProcessGrayMorphErode(src_image, dst_image, kernel_size)) {imImageDestroy(temp); return 0;} + if (!imProcessGrayMorphDilate(src_image, temp, kernel_size)) + {imImageDestroy(temp); return 0;} + if (!imProcessGrayMorphErode(src_image, dst_image, kernel_size)) + {imImageDestroy(temp); return 0;} imProcessArithmeticOp(temp, dst_image, dst_image, IM_BIN_DIFF); |