29#include "moo_badpix.h"
60 cpl_ensure_code(badpix != NULL, CPL_ERROR_NULL_INPUT);
61 cpl_ensure_code(mask != NULL, CPL_ERROR_NULL_INPUT);
63 cpl_type type = cpl_image_get_type(badpix);
64 cpl_ensure_code(type == CPL_TYPE_INT, CPL_ERROR_ILLEGAL_INPUT);
66 int nx = cpl_image_get_size_x(badpix);
67 int ny = cpl_image_get_size_y(badpix);
68 int mask_nx = cpl_mask_get_size_x(mask);
69 int mask_ny = cpl_mask_get_size_y(mask);
70 cpl_ensure_code(nx == mask_nx, CPL_ERROR_ILLEGAL_INPUT);
71 cpl_ensure_code(ny == mask_ny, CPL_ERROR_ILLEGAL_INPUT);
73 int *data = cpl_image_get_data_int(badpix);
74 cpl_binary *mdata = cpl_mask_get_data(mask);
77 for (i = 0; i < nx * ny; i++) {
78 if ((data[i] & level) > 0) {
85 return CPL_ERROR_NONE;
107 cpl_ensure_code(badpix != NULL, CPL_ERROR_NULL_INPUT);
108 cpl_ensure_code(mask != NULL, CPL_ERROR_NULL_INPUT);
110 cpl_type type = cpl_image_get_type(badpix);
111 cpl_ensure_code(type == CPL_TYPE_INT, CPL_ERROR_ILLEGAL_INPUT);
113 int nx = cpl_image_get_size_x(badpix);
114 int ny = cpl_image_get_size_y(badpix);
115 int mask_nx = cpl_mask_get_size_x(mask);
116 int mask_ny = cpl_mask_get_size_y(mask);
117 cpl_ensure_code(nx == mask_nx, CPL_ERROR_ILLEGAL_INPUT);
118 cpl_ensure_code(ny == mask_ny, CPL_ERROR_ILLEGAL_INPUT);
120 int *data = cpl_image_get_data_int(badpix);
121 cpl_binary *mdata = cpl_mask_get_data(mask);
124 for (i = 0; i < nx * ny; i++) {
129 return CPL_ERROR_NONE;
148 cpl_ensure_code(badpix1 != NULL, CPL_ERROR_NULL_INPUT);
149 cpl_ensure_code(badpix2 != NULL, CPL_ERROR_NULL_INPUT);
151 cpl_type type1 = cpl_image_get_type(badpix1);
152 cpl_ensure_code(type1 == CPL_TYPE_INT, CPL_ERROR_ILLEGAL_INPUT);
153 cpl_type type2 = cpl_image_get_type(badpix2);
154 cpl_ensure_code(type2 == CPL_TYPE_INT, CPL_ERROR_ILLEGAL_INPUT);
156 int nx = cpl_image_get_size_x(badpix1);
157 int ny = cpl_image_get_size_y(badpix1);
158 int nx2 = cpl_image_get_size_x(badpix2);
159 int ny2 = cpl_image_get_size_y(badpix2);
161 cpl_ensure_code(nx == nx2, CPL_ERROR_ILLEGAL_INPUT);
162 cpl_ensure_code(ny == ny2, CPL_ERROR_ILLEGAL_INPUT);
163 int *data1 = cpl_image_get_data_int(badpix1);
164 int *data2 = cpl_image_get_data_int(badpix2);
167 for (i = 0; i < nx * ny; i++) {
168 data1[i] |= data2[i];
170 return CPL_ERROR_NONE;
cpl_error_code moo_mask_to_badpix(cpl_image *badpix, cpl_mask *mask, unsigned int level)
Add the mask of the badpix level to the badpix map.
cpl_error_code moo_badpix_merge(cpl_image *badpix1, cpl_image *badpix2)
Merge to bad pixel map.
cpl_error_code moo_badpix_to_mask(cpl_image *badpix, cpl_mask *mask, unsigned int level)
Apply the badpix map on the given mask.