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 2142 of file rt_band.c.
2146 {
2147 double minval = 0.;
2148
2149 assert(NULL != band);
2150 assert(NULL != newval);
2151
2152 if (corrected != NULL)
2153 *corrected = 0;
2154
2155
2157 *newval = val;
2159 }
2160
2162 *newval = val;
2163
2164 switch (
band->pixtype) {
2166 *newval = !
band->nodataval;
2167 break;
2170 (*newval)++;
2171 else
2172 (*newval)--;
2173 break;
2176 (*newval)++;
2177 else
2178 (*newval)--;
2179 break;
2182 (*newval)++;
2183 else
2184 (*newval)--;
2185 break;
2188 (*newval)++;
2189 else
2190 (*newval)--;
2191 break;
2194 (*newval)++;
2195 else
2196 (*newval)--;
2197 break;
2200 (*newval)++;
2201 else
2202 (*newval)--;
2203 break;
2206 (*newval)++;
2207 else
2208 (*newval)--;
2209 break;
2212 (*newval)++;
2213 else
2214 (*newval)--;
2215 break;
2218 *newval += FLT_EPSILON;
2219 else
2220 *newval -= FLT_EPSILON;
2221 break;
2223 break;
2224 default:
2225 rterror(
"rt_band_corrected_clamped_value: Unknown pixeltype %d",
band->pixtype);
2227 }
2228
2229 if (corrected != NULL)
2230 *corrected = 1;
2231
2233}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
int8_t rt_util_clamp_to_8BSI(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_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_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().