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 1834 of file rt_band.c.
1838 {
1839 double minval = 0.;
1840
1841 assert(NULL != band);
1842 assert(NULL != newval);
1843
1844 if (corrected != NULL)
1845 *corrected = 0;
1846
1847
1849 *newval = val;
1851 }
1852
1854 *newval = val;
1855
1856 switch (
band->pixtype) {
1858 *newval = !
band->nodataval;
1859 break;
1862 (*newval)++;
1863 else
1864 (*newval)--;
1865 break;
1868 (*newval)++;
1869 else
1870 (*newval)--;
1871 break;
1874 (*newval)++;
1875 else
1876 (*newval)--;
1877 break;
1880 (*newval)++;
1881 else
1882 (*newval)--;
1883 break;
1886 (*newval)++;
1887 else
1888 (*newval)--;
1889 break;
1892 (*newval)++;
1893 else
1894 (*newval)--;
1895 break;
1898 (*newval)++;
1899 else
1900 (*newval)--;
1901 break;
1904 (*newval)++;
1905 else
1906 (*newval)--;
1907 break;
1910 *newval += FLT_EPSILON;
1911 else
1912 *newval -= FLT_EPSILON;
1913 break;
1915 break;
1916 default:
1917 rterror(
"rt_band_corrected_clamped_value: Unknown pixeltype %d",
band->pixtype);
1919 }
1920
1921 if (corrected != NULL)
1922 *corrected = 1;
1923
1925}
void rterror(const char *fmt,...)
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().