diff --git a/scripts/examples/01-Camera/02-Optical-Flow/absolute-rotation-scale.py b/scripts/examples/01-Camera/02-Optical-Flow/absolute-rotation-scale.py index 2a95896d4..40b83e3fa 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/absolute-rotation-scale.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/absolute-rotation-scale.py @@ -23,7 +23,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/01-Camera/02-Optical-Flow/absolute-translation.py b/scripts/examples/01-Camera/02-Optical-Flow/absolute-translation.py index ac3a7bbfe..ef76c0d81 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/absolute-translation.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/absolute-translation.py @@ -23,7 +23,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/01-Camera/02-Optical-Flow/differential-rotation-scale.py b/scripts/examples/01-Camera/02-Optical-Flow/differential-rotation-scale.py index 613dd25a6..dae1321c8 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/differential-rotation-scale.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/differential-rotation-scale.py @@ -23,7 +23,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/01-Camera/02-Optical-Flow/differential-translation.py b/scripts/examples/01-Camera/02-Optical-Flow/differential-translation.py index 5bed84f3f..e00a2a346 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/differential-translation.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/differential-translation.py @@ -23,7 +23,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-rotation-scale.py b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-rotation-scale.py index 0d31e2711..17c2d37aa 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-rotation-scale.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-rotation-scale.py @@ -30,7 +30,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-translation.py b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-translation.py index ccc53d009..c46870b3a 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-translation.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-absolute-translation.py @@ -30,7 +30,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-rotation-scale.py b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-rotation-scale.py index 0a96e287b..a83c0e058 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-rotation-scale.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-rotation-scale.py @@ -30,7 +30,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time import math diff --git a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-translation.py b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-translation.py index 819de19a7..5f5f07f37 100644 --- a/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-translation.py +++ b/scripts/examples/01-Camera/02-Optical-Flow/image-patches-differential-translation.py @@ -30,7 +30,7 @@ # # Your OpenMV Cam supports power of 2 resolutions of 64x32, 64x64, # 128x64, and 128x128. If you want a resolution of 32x32 you can create -# it by doing "img.pool(2, 2)" on a 64x64 image. +# it by doing "img.scale(x_scale=0.5, y_scale=0.5, hint=image.AREA)" on a 64x64 image. import sensor import time diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing.py index a76a6fbbe..944487604 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing.py @@ -8,6 +8,7 @@ import sensor import time +import image sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -19,7 +20,7 @@ while True: clock.tick() img = sensor.snapshot() - small_img = img.mean_pooled(4, 4) # Makes a copy. + small_img = img.scale(x_scale=0.25, y_scale=0.25, hint=image.AREA, copy=True) x = (img.width() // 2) - (small_img.width() // 2) y = (img.height() // 2) - (small_img.height() // 2) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_advanced.py b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_advanced.py index 922db7649..3a01a861c 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_advanced.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/image_drawing_advanced.py @@ -55,7 +55,9 @@ while True: img = sensor.snapshot() # Makes a scaled copy of the sensor - small_img = img.mean_pooled(SMALL_IMAGE_SCALE, SMALL_IMAGE_SCALE) + small_img = img.scale(x_scale=1.0 / SMALL_IMAGE_SCALE, + y_scale=1.0 / SMALL_IMAGE_SCALE, + hint=image.AREA, copy=True) status = "rgb565 " if CYCLE_FORMATS: diff --git a/src/omv/Makefile b/src/omv/Makefile index cc2cde430..cc9acfcfa 100644 --- a/src/omv/Makefile +++ b/src/omv/Makefile @@ -90,7 +90,6 @@ SRCS += $(addprefix imlib/, \ orb.c \ phasecorrelation.c \ point.c \ - pool.c \ ppm.c \ qrcode.c \ qsort.c \ diff --git a/src/omv/boards/ARDUINO_GIGA/imlib_config.h b/src/omv/boards/ARDUINO_GIGA/imlib_config.h index 864bcd0e5..23f2bd58c 100644 --- a/src/omv/boards/ARDUINO_GIGA/imlib_config.h +++ b/src/omv/boards/ARDUINO_GIGA/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/ARDUINO_NANO_33_BLE_SENSE/imlib_config.h b/src/omv/boards/ARDUINO_NANO_33_BLE_SENSE/imlib_config.h index aa5125b0a..29a5d3b74 100644 --- a/src/omv/boards/ARDUINO_NANO_33_BLE_SENSE/imlib_config.h +++ b/src/omv/boards/ARDUINO_NANO_33_BLE_SENSE/imlib_config.h @@ -24,12 +24,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -//#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -//#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops //#define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/imlib_config.h b/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/imlib_config.h index 31fb76237..3d1f372a4 100644 --- a/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/imlib_config.h +++ b/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -//#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -//#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops //#define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/ARDUINO_NICLA_VISION/imlib_config.h b/src/omv/boards/ARDUINO_NICLA_VISION/imlib_config.h index 416de40f0..dd87caf6e 100644 --- a/src/omv/boards/ARDUINO_NICLA_VISION/imlib_config.h +++ b/src/omv/boards/ARDUINO_NICLA_VISION/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/ARDUINO_PORTENTA_H7/imlib_config.h b/src/omv/boards/ARDUINO_PORTENTA_H7/imlib_config.h index d6af847e2..284fb9bbe 100644 --- a/src/omv/boards/ARDUINO_PORTENTA_H7/imlib_config.h +++ b/src/omv/boards/ARDUINO_PORTENTA_H7/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMV2/imlib_config.h b/src/omv/boards/OPENMV2/imlib_config.h index 269319c81..e77006e60 100644 --- a/src/omv/boards/OPENMV2/imlib_config.h +++ b/src/omv/boards/OPENMV2/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMV3/imlib_config.h b/src/omv/boards/OPENMV3/imlib_config.h index 2bfe9d876..cf1e3b3b0 100644 --- a/src/omv/boards/OPENMV3/imlib_config.h +++ b/src/omv/boards/OPENMV3/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMV4/imlib_config.h b/src/omv/boards/OPENMV4/imlib_config.h index 192e93b9d..ab97976c0 100644 --- a/src/omv/boards/OPENMV4/imlib_config.h +++ b/src/omv/boards/OPENMV4/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMV4P/imlib_config.h b/src/omv/boards/OPENMV4P/imlib_config.h index 06f981c0c..9c45de94d 100644 --- a/src/omv/boards/OPENMV4P/imlib_config.h +++ b/src/omv/boards/OPENMV4P/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMV4_PRO/imlib_config.h b/src/omv/boards/OPENMV4_PRO/imlib_config.h index 06f981c0c..9c45de94d 100644 --- a/src/omv/boards/OPENMV4_PRO/imlib_config.h +++ b/src/omv/boards/OPENMV4_PRO/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMVPT/imlib_config.h b/src/omv/boards/OPENMVPT/imlib_config.h index 06f981c0c..9c45de94d 100644 --- a/src/omv/boards/OPENMVPT/imlib_config.h +++ b/src/omv/boards/OPENMVPT/imlib_config.h @@ -23,12 +23,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/OPENMV_RT1060/imlib_config.h b/src/omv/boards/OPENMV_RT1060/imlib_config.h index 358c2d5c3..88d1a34c7 100644 --- a/src/omv/boards/OPENMV_RT1060/imlib_config.h +++ b/src/omv/boards/OPENMV_RT1060/imlib_config.h @@ -22,12 +22,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops #define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/boards/PICO/imlib_config.h b/src/omv/boards/PICO/imlib_config.h index 75551d25e..391e0b6ac 100644 --- a/src/omv/boards/PICO/imlib_config.h +++ b/src/omv/boards/PICO/imlib_config.h @@ -24,12 +24,6 @@ // Enable YUV LUT //#define IMLIB_ENABLE_YUV_LUT -// Enable mean pooling -//#define IMLIB_ENABLE_MEAN_POOLING - -// Enable midpoint pooling -//#define IMLIB_ENABLE_MIDPOINT_POOLING - // Enable ISP ops //#define IMLIB_ENABLE_ISP_OPS diff --git a/src/omv/imlib/pool.c b/src/omv/imlib/pool.c deleted file mode 100644 index 9a31266b3..000000000 --- a/src/omv/imlib/pool.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013-2016 Kwabena W. Agyeman - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * Image pooling. - * - */ -#include "imlib.h" - -#ifdef IMLIB_ENABLE_MIDPOINT_POOLING -void imlib_midpoint_pool(image_t *img_i, image_t *img_o, int x_div, int y_div, const int bias) { - int min_bias = (256 - bias); - int max_bias = bias; - switch (img_i->pixfmt) { - case PIXFORMAT_BINARY: { - for (int y = 0, yy = img_i->h / y_div, yyy = (img_i->h % y_div) / 2; y < yy; y++) { - uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img_o, y); - for (int x = 0, xx = img_i->w / x_div, xxx = (img_i->w % x_div) / 2; x < xx; x++) { - int min = COLOR_BINARY_MAX, max = COLOR_BINARY_MIN; - for (int i = 0; i < y_div; i++) { - for (int j = 0; j < x_div; j++) { - int pixel = IMAGE_GET_BINARY_PIXEL(img_i, xxx + (x * x_div) + j, yyy + (y * y_div) + i); - min = IM_MIN(min, pixel); - max = IM_MAX(max, pixel); - } - } - IMAGE_PUT_BINARY_PIXEL_FAST(row_ptr, x, - ((min * min_bias) + (max * max_bias)) >> 8); - } - } - break; - } - case PIXFORMAT_GRAYSCALE: { - for (int y = 0, yy = img_i->h, yyy = (img_i->h % y_div) / 2; y < yy; y++) { - uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img_o, y); - for (int x = 0, xx = img_i->w / x_div, xxx = (img_i->w % x_div) / 2; x < xx; x++) { - int min = COLOR_GRAYSCALE_MAX, max = COLOR_GRAYSCALE_MIN; - for (int i = 0; i < y_div; i++) { - for (int j = 0; j < x_div; j++) { - int pixel = IMAGE_GET_GRAYSCALE_PIXEL(img_i, xxx + (x * x_div) + j, yyy + (y * y_div) + i); - min = IM_MIN(min, pixel); - max = IM_MAX(max, pixel); - } - } - IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_ptr, x, - ((min * min_bias) + (max * max_bias)) >> 8); - } - } - break; - } - case PIXFORMAT_RGB565: { - for (int y = 0, yy = img_i->h / y_div, yyy = (img_i->h % y_div) / 2; y < yy; y++) { - uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img_o, y); - for (int x = 0, xx = img_i->w / x_div, xxx = (img_i->w % x_div) / 2; x < xx; x++) { - int r_min = COLOR_R5_MAX, r_max = COLOR_R5_MIN; - int g_min = COLOR_G6_MAX, g_max = COLOR_G6_MIN; - int b_min = COLOR_B5_MAX, b_max = COLOR_B5_MIN; - for (int i = 0; i < y_div; i++) { - for (int j = 0; j < x_div; j++) { - const uint16_t pixel = IM_GET_RGB565_PIXEL(img_i, xxx + (x * x_div) + j, yyy + (y * y_div) + i); - int r = COLOR_RGB565_TO_R5(pixel); - int g = COLOR_RGB565_TO_G6(pixel); - int b = COLOR_RGB565_TO_B5(pixel); - r_min = IM_MIN(r_min, r); - r_max = IM_MAX(r_max, r); - g_min = IM_MIN(g_min, g); - g_max = IM_MAX(g_max, g); - b_min = IM_MIN(b_min, b); - b_max = IM_MAX(b_max, b); - } - } - IMAGE_PUT_RGB565_PIXEL_FAST(row_ptr, x, - COLOR_R5_G6_B5_TO_RGB565(((r_min * min_bias) + (r_max * max_bias)) >> 8, - ((g_min * min_bias) + (g_max * max_bias)) >> 8, - ((b_min * min_bias) + (b_max * max_bias)) >> 8)); - } - } - break; - } - default: { - break; - } - } -} -#endif // IMLIB_ENABLE_MIDPOINT_POOLING - -#ifdef IMLIB_ENABLE_MEAN_POOLING -void imlib_mean_pool(image_t *img_i, image_t *img_o, int x_div, int y_div) { - int n = x_div * y_div; - switch (img_i->pixfmt) { - case PIXFORMAT_BINARY: { - for (int y = 0, yy = img_i->h / y_div, yyy = (img_i->h % y_div) / 2; y < yy; y++) { - uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img_o, y); - for (int x = 0, xx = img_i->w / x_div, xxx = (img_i->w % x_div) / 2; x < xx; x++) { - int acc = 0; - for (int i = 0; i < y_div; i++) { - for (int j = 0; j < x_div; j++) { - int pixel = IMAGE_GET_BINARY_PIXEL(img_i, xxx + (x * x_div) + j, yyy + (y * y_div) + i); - acc += pixel; - } - } - IMAGE_PUT_BINARY_PIXEL_FAST(row_ptr, x, acc / n); - } - } - break; - } - case PIXFORMAT_GRAYSCALE: { - for (int y = 0, yy = img_i->h / y_div, yyy = (img_i->h % y_div) / 2; y < yy; y++) { - uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img_o, y); - for (int x = 0, xx = img_i->w / x_div, xxx = (img_i->w % x_div) / 2; x < xx; x++) { - int acc = 0; - for (int i = 0; i < y_div; i++) { - for (int j = 0; j < x_div; j++) { - int pixel = IMAGE_GET_GRAYSCALE_PIXEL(img_i, xxx + (x * x_div) + j, yyy + (y * y_div) + i); - acc += pixel; - } - } - IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_ptr, x, acc / n); - } - } - break; - } - case PIXFORMAT_RGB565: { - for (int y = 0, yy = img_i->h / y_div, yyy = (img_i->h % y_div) / 2; y < yy; y++) { - uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img_o, y); - for (int x = 0, xx = img_i->w / x_div, xxx = (img_i->w % x_div) / 2; x < xx; x++) { - int r_acc = 0; - int g_acc = 0; - int b_acc = 0; - for (int i = 0; i < y_div; i++) { - for (int j = 0; j < x_div; j++) { - int pixel = IMAGE_GET_RGB565_PIXEL(img_i, xxx + (x * x_div) + j, yyy + (y * y_div) + i); - r_acc += COLOR_RGB565_TO_R5(pixel); - g_acc += COLOR_RGB565_TO_G6(pixel); - b_acc += COLOR_RGB565_TO_B5(pixel); - } - } - IMAGE_PUT_RGB565_PIXEL_FAST(row_ptr, x, COLOR_R5_G6_B5_TO_RGB565(r_acc / n, g_acc / n, b_acc / n)); - } - } - break; - } - default: { - break; - } - } -} -#endif // IMLIB_ENABLE_MEAN_POOLING diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index 4ba7889aa..3a4b576a7 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -840,108 +840,6 @@ STATIC mp_obj_t py_image_set_pixel(uint n_args, const mp_obj_t *args, mp_map_t * } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_set_pixel_obj, 2, py_image_set_pixel); -#ifdef IMLIB_ENABLE_MEAN_POOLING -static mp_obj_t py_image_mean_pool(mp_obj_t img_obj, mp_obj_t x_div_obj, mp_obj_t y_div_obj) { - image_t *arg_img = py_helper_arg_to_image(img_obj, ARG_IMAGE_MUTABLE); - - int arg_x_div = mp_obj_get_int(x_div_obj); - PY_ASSERT_TRUE_MSG(arg_x_div >= 1, "Width divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_x_div <= arg_img->w, "Width divisor must be less than <= img width"); - int arg_y_div = mp_obj_get_int(y_div_obj); - PY_ASSERT_TRUE_MSG(arg_y_div >= 1, "Height divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_y_div <= arg_img->h, "Height divisor must be less than <= img height"); - - image_t out_img; - out_img.w = arg_img->w / arg_x_div; - out_img.h = arg_img->h / arg_y_div; - out_img.pixfmt = arg_img->pixfmt; - out_img.pixels = arg_img->pixels; - PY_ASSERT_TRUE_MSG(image_size(&out_img) <= image_size(arg_img), "Can't pool in place!"); - - imlib_mean_pool(arg_img, &out_img, arg_x_div, arg_y_div); - arg_img->w = out_img.w; - arg_img->h = out_img.h; - py_helper_update_framebuffer(arg_img); - return img_obj; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_mean_pool_obj, py_image_mean_pool); - -static mp_obj_t py_image_mean_pooled(mp_obj_t img_obj, mp_obj_t x_div_obj, mp_obj_t y_div_obj) { - image_t *arg_img = py_helper_arg_to_image(img_obj, ARG_IMAGE_MUTABLE); - - int arg_x_div = mp_obj_get_int(x_div_obj); - PY_ASSERT_TRUE_MSG(arg_x_div >= 1, "Width divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_x_div <= arg_img->w, "Width divisor must be less than <= img width"); - int arg_y_div = mp_obj_get_int(y_div_obj); - PY_ASSERT_TRUE_MSG(arg_y_div >= 1, "Height divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_y_div <= arg_img->h, "Height divisor must be less than <= img height"); - - image_t out_img; - out_img.w = arg_img->w / arg_x_div; - out_img.h = arg_img->h / arg_y_div; - out_img.pixfmt = arg_img->pixfmt; - out_img.pixels = xalloc(image_size(&out_img)); - - imlib_mean_pool(arg_img, &out_img, arg_x_div, arg_y_div); - return py_image_from_struct(&out_img); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_mean_pooled_obj, py_image_mean_pooled); -#endif // IMLIB_ENABLE_MEAN_POOLING - -#ifdef IMLIB_ENABLE_MIDPOINT_POOLING -static mp_obj_t py_image_midpoint_pool(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { - image_t *arg_img = py_helper_arg_to_image(args[0], ARG_IMAGE_MUTABLE); - - int arg_x_div = mp_obj_get_int(args[1]); - PY_ASSERT_TRUE_MSG(arg_x_div >= 1, "Width divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_x_div <= arg_img->w, "Width divisor must be less than <= img width"); - int arg_y_div = mp_obj_get_int(args[2]); - PY_ASSERT_TRUE_MSG(arg_y_div >= 1, "Height divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_y_div <= arg_img->h, "Height divisor must be less than <= img height"); - - int arg_bias = py_helper_keyword_float(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_bias), 0.5) * 256; - PY_ASSERT_TRUE_MSG((0 <= arg_bias) && (arg_bias <= 256), "Error: 0 <= bias <= 1!"); - - image_t out_img; - out_img.w = arg_img->w / arg_x_div; - out_img.h = arg_img->h / arg_y_div; - out_img.pixfmt = arg_img->pixfmt; - out_img.pixels = arg_img->pixels; - PY_ASSERT_TRUE_MSG(image_size(&out_img) <= image_size(arg_img), "Can't pool in place!"); - - imlib_midpoint_pool(arg_img, &out_img, arg_x_div, arg_y_div, arg_bias); - arg_img->w = out_img.w; - arg_img->h = out_img.h; - py_helper_update_framebuffer(arg_img); - return args[0]; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_midpoint_pool_obj, 3, py_image_midpoint_pool); - -static mp_obj_t py_image_midpoint_pooled(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { - image_t *arg_img = py_helper_arg_to_image(args[0], ARG_IMAGE_MUTABLE); - - int arg_x_div = mp_obj_get_int(args[1]); - PY_ASSERT_TRUE_MSG(arg_x_div >= 1, "Width divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_x_div <= arg_img->w, "Width divisor must be less than <= img width"); - int arg_y_div = mp_obj_get_int(args[2]); - PY_ASSERT_TRUE_MSG(arg_y_div >= 1, "Height divisor must be greater than >= 1"); - PY_ASSERT_TRUE_MSG(arg_y_div <= arg_img->h, "Height divisor must be less than <= img height"); - - int arg_bias = py_helper_keyword_float(n_args, args, 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_bias), 0.5) * 256; - PY_ASSERT_TRUE_MSG((0 <= arg_bias) && (arg_bias <= 256), "Error: 0 <= bias <= 1!"); - - image_t out_img; - out_img.w = arg_img->w / arg_x_div; - out_img.h = arg_img->h / arg_y_div; - out_img.pixfmt = arg_img->pixfmt; - out_img.pixels = xalloc(image_size(&out_img)); - - imlib_midpoint_pool(arg_img, &out_img, arg_x_div, arg_y_div, arg_bias); - return py_image_from_struct(&out_img); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_midpoint_pooled_obj, 3, py_image_midpoint_pooled); -#endif // IMLIB_ENABLE_MIDPOINT_POOLING - static mp_obj_t py_image_to(pixformat_t pixfmt, mp_rom_obj_t default_color_palette, bool default_copy, uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { @@ -6271,20 +6169,6 @@ static const mp_rom_map_elem_t locals_dict_table[] = { {MP_ROM_QSTR(MP_QSTR_bytearray), MP_ROM_PTR(&py_image_bytearray_obj)}, {MP_ROM_QSTR(MP_QSTR_get_pixel), MP_ROM_PTR(&py_image_get_pixel_obj)}, {MP_ROM_QSTR(MP_QSTR_set_pixel), MP_ROM_PTR(&py_image_set_pixel_obj)}, - #ifdef IMLIB_ENABLE_MEAN_POOLING - {MP_ROM_QSTR(MP_QSTR_mean_pool), MP_ROM_PTR(&py_image_mean_pool_obj)}, - {MP_ROM_QSTR(MP_QSTR_mean_pooled), MP_ROM_PTR(&py_image_mean_pooled_obj)}, - #else - {MP_ROM_QSTR(MP_QSTR_mean_pool), MP_ROM_PTR(&py_func_unavailable_obj)}, - {MP_ROM_QSTR(MP_QSTR_mean_pooled), MP_ROM_PTR(&py_func_unavailable_obj)}, - #endif - #ifdef IMLIB_ENABLE_MIDPOINT_POOLING - {MP_ROM_QSTR(MP_QSTR_midpoint_pool), MP_ROM_PTR(&py_image_midpoint_pool_obj)}, - {MP_ROM_QSTR(MP_QSTR_midpoint_pooled), MP_ROM_PTR(&py_image_midpoint_pooled_obj)}, - #else - {MP_ROM_QSTR(MP_QSTR_midpoint_pool), MP_ROM_PTR(&py_func_unavailable_obj)}, - {MP_ROM_QSTR(MP_QSTR_midpoint_pooled), MP_ROM_PTR(&py_func_unavailable_obj)}, - #endif {MP_ROM_QSTR(MP_QSTR_to_bitmap), MP_ROM_PTR(&py_image_to_bitmap_obj)}, {MP_ROM_QSTR(MP_QSTR_to_grayscale), MP_ROM_PTR(&py_image_to_grayscale_obj)}, {MP_ROM_QSTR(MP_QSTR_to_rgb565), MP_ROM_PTR(&py_image_to_rgb565_obj)}, diff --git a/src/omv/ports/mimxrt/omv_portconfig.mk b/src/omv/ports/mimxrt/omv_portconfig.mk index 55b368617..18cc54c20 100644 --- a/src/omv/ports/mimxrt/omv_portconfig.mk +++ b/src/omv/ports/mimxrt/omv_portconfig.mk @@ -203,7 +203,6 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \ orb.o \ phasecorrelation.o \ point.o \ - pool.o \ ppm.o \ qrcode.o \ qsort.o \ diff --git a/src/omv/ports/nrf/omv_portconfig.mk b/src/omv/ports/nrf/omv_portconfig.mk index 3830c0706..dcc3fe3cb 100644 --- a/src/omv/ports/nrf/omv_portconfig.mk +++ b/src/omv/ports/nrf/omv_portconfig.mk @@ -169,7 +169,6 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \ orb.o \ phasecorrelation.o \ point.o \ - pool.o \ ppm.o \ qrcode.o \ qsort.o \ diff --git a/src/omv/ports/rp2/omv_portconfig.cmake b/src/omv/ports/rp2/omv_portconfig.cmake index b9b442d6a..5c185ed16 100644 --- a/src/omv/ports/rp2/omv_portconfig.cmake +++ b/src/omv/ports/rp2/omv_portconfig.cmake @@ -162,7 +162,6 @@ target_sources(${MICROPY_TARGET} PRIVATE ${TOP_DIR}/${OMV_DIR}/imlib/orb.c ${TOP_DIR}/${OMV_DIR}/imlib/phasecorrelation.c ${TOP_DIR}/${OMV_DIR}/imlib/point.c - ${TOP_DIR}/${OMV_DIR}/imlib/pool.c ${TOP_DIR}/${OMV_DIR}/imlib/ppm.c ${TOP_DIR}/${OMV_DIR}/imlib/qrcode.c ${TOP_DIR}/${OMV_DIR}/imlib/qsort.c diff --git a/src/omv/ports/stm32/omv_portconfig.mk b/src/omv/ports/stm32/omv_portconfig.mk index a668e8958..f619bb452 100644 --- a/src/omv/ports/stm32/omv_portconfig.mk +++ b/src/omv/ports/stm32/omv_portconfig.mk @@ -218,7 +218,6 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \ orb.o \ phasecorrelation.o \ point.o \ - pool.o \ ppm.o \ qrcode.o \ qsort.o \