Search band for pixel(s) with search values.
- Parameters
-
band | : the band to query for minimum and maximum pixel values |
exclude_nodata_value | : if non-zero, ignore nodata values |
searchset | : array of values to count |
searchcount | : the number of search values |
pixels | : pixels with the search value |
- Returns
- -1 on error, otherwise number of pixels
Definition at line 1519 of file rt_band.c.
References genraster::count, ES_NONE, FALSE, FLT_NEQ, rt_band_t::hasnodata, rt_band_t::height, rt_band_t::isnodata, rt_pixel_t::nodata, pixval::pixel, rt_band_t::pixtype, pixval::pixval, RASTER_DEBUG, rt_band_get_pixel(), rt_pixtype_compare_clamped_values(), rtalloc(), rterror(), rtrealloc(), rt_pixel_t::value, rt_band_t::width, pixval::x, rt_pixel_t::x, pixval::y, and rt_pixel_t::y.
Referenced by RASTER_pixelOfValue(), and test_band_get_pixel_of_value().
1535 assert(NULL != band);
1536 assert(NULL != pixels);
1537 assert(NULL != searchset && searchcount > 0);
1540 exclude_nodata_value =
FALSE;
1542 else if (exclude_nodata_value && band->
isnodata) {
1543 RASTER_DEBUG(4,
"Pixels cannot be searched as band is NODATA and excluding NODATA values");
1547 for (x = 0; x < band->
width; x++) {
1548 for (y = 0; y < band->
height; y++) {
1551 rterror(
"rt_band_get_pixel_of_value: Cannot get band pixel");
1554 else if (exclude_nodata_value && isnodata)
1557 for (i = 0; i < searchcount; i++) {
1562 if (
FLT_NEQ(pixval, searchset[i]) || !isequal)
1567 if (*pixels == NULL)
1571 if (*pixels == NULL) {
1572 rterror(
"rt_band_get_pixel_of_value: Could not allocate memory for pixel(s)");
1576 pixel = &((*pixels)[count - 1]);
struct rt_pixel_t * rt_pixel
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
void * rtrealloc(void *mem, size_t size)
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
#define RASTER_DEBUG(level, msg)
rt_errorstate rt_pixtype_compare_clamped_values(rt_pixtype pixtype, double val, double refval, int *isequal)
Test to see if two values are equal when clamped.