Correct value when clamped value is equal to clamped NODATA value.
Correction does NOT occur if unclamped value is exactly unclamped NODATA value.
- Parameters
-
| band | : the band whose NODATA value will be used for comparison |
| val | : the value to compare to the NODATA value and correct |
| *newval | : pointer to corrected value |
| *corrected | : (optional) non-zero if val was corrected |
- Returns
- ES_NONE if success, ES_ERROR if error
Definition at line 2171 of file rt_band.c.
2175 {
2176 double minval = 0.;
2177
2178 assert(NULL != band);
2179 assert(NULL != newval);
2180
2181 if (corrected != NULL)
2182 *corrected = 0;
2183
2184
2186 *newval = val;
2188 }
2189
2191 *newval = val;
2192
2193 switch (
band->pixtype) {
2195 *newval = !
band->nodataval;
2196 break;
2199 (*newval)++;
2200 else
2201 (*newval)--;
2202 break;
2205 (*newval)++;
2206 else
2207 (*newval)--;
2208 break;
2211 (*newval)++;
2212 else
2213 (*newval)--;
2214 break;
2217 (*newval)++;
2218 else
2219 (*newval)--;
2220 break;
2223 (*newval)++;
2224 else
2225 (*newval)--;
2226 break;
2229 (*newval)++;
2230 else
2231 (*newval)--;
2232 break;
2235 (*newval)++;
2236 else
2237 (*newval)--;
2238 break;
2241 (*newval)++;
2242 else
2243 (*newval)--;
2244 break;
2247 *newval += FLT_EPSILON;
2248 else
2249 *newval -= FLT_EPSILON;
2250 break;
2253 *newval += FLT_EPSILON;
2254 else
2255 *newval -= FLT_EPSILON;
2256 break;
2258 break;
2259 default:
2260 rterror(
"rt_band_corrected_clamped_value: Unknown pixeltype %d",
band->pixtype);
2262 }
2263
2264 if (corrected != NULL)
2265 *corrected = 1;
2266
2268}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
int8_t rt_util_clamp_to_8BSI(double value)
float rt_util_clamp_to_16F(double value)
int32_t rt_util_clamp_to_32BSI(double value)
double rt_pixtype_get_min_value(rt_pixtype pixtype)
Return minimum value possible for pixel type.
uint8_t rt_util_clamp_to_2BUI(double value)
uint8_t rt_util_clamp_to_8BUI(double value)
int16_t rt_util_clamp_to_16BSI(double value)
uint8_t rt_util_clamp_to_4BUI(double value)
uint16_t rt_util_clamp_to_16BUI(double value)
uint32_t rt_util_clamp_to_32BUI(double value)
float rt_util_clamp_to_32F(double value)
int rt_band_clamped_value_is_nodata(rt_band band, double val)
Compare clamped value to band's clamped NODATA value.
References ES_ERROR, ES_NONE, FLT_EQ, PT_16BF, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, rt_band_clamped_value_is_nodata(), rt_pixtype_get_min_value(), rt_util_clamp_to_16BSI(), rt_util_clamp_to_16BUI(), rt_util_clamp_to_16F(), rt_util_clamp_to_2BUI(), rt_util_clamp_to_32BSI(), rt_util_clamp_to_32BUI(), rt_util_clamp_to_32F(), rt_util_clamp_to_4BUI(), rt_util_clamp_to_8BSI(), rt_util_clamp_to_8BUI(), and rterror().
Referenced by rt_band_set_pixel().