23 if (d >= 0.0 && d <= 1.0) {
24 return ((a+2.0) * d * d * d - (a+3.0) * d * d + 1.0);
26 if (d > 1.0 && d <= 2.0) {
27 return (a * d * d * d - 5.0 * a * d * d + 8.0 * a * d - 4.0 * a);
80 if (Source->
nline < 1) {
97 if (Source_mask == NULL) {
120 if (Line->
nline < 1) {
137 if (Sample == NULL) {
166 if (Resampled == NULL) {
174 if (Resampled_mask == NULL) {
194 for (iline = 0; iline < Line->
nline ; iline++) {
195 for (isample = 0; isample < Line->
nsample; isample++) {
196 float pline = Line->
data.
f[iline][isample];
198 float psample = Sample->
data.
f[iline][isample];
200 int pline_int = (int)floor(pline + 0.5);
203 int psample_int = (int)floor(psample + 0.5);
206 float missing_default;
213 float resampled_value = 0.0;
221 if (pline_int < 0 || pline_int >= Source->
nline ||
222 psample_int < 0 || psample_int >= Source->
nsample) {
226 if (!Source_mask->
data.
u8[pline_int][psample_int]) {
235 missing_default = Source->
data.
f[pline_int][psample_int];
241 start_line = (int)floor(pline-1);
242 start_sample = (int)floor(psample-1);
243 end_line = start_line + 4;
244 end_sample = start_sample + 4;
250 for (wline = start_line ; wline < end_line; wline++) {
251 for (wsample = start_sample ; wsample < end_sample; wsample++) {
267 if (wline < 0 || wline >= Source->
nline ||
268 wsample < 0 || wsample >= Source->
nsample) {
271 if (!Source_mask->
data.
u8[wline][wsample]) {
277 wvalue = Source->
data.
f[wline][wsample];
279 wvalue = missing_default;
286 dline = fabs((
float)wline - pline);
287 dsample = fabs((
float)wsample - psample);
293 resampled_value += wvalue *
kernel(dline,A) *
kernel(dsample,A);
306 resampled_tmp.
data.
f[iline][isample] = resampled_value;
307 resampled_mask_tmp.
data.
u8[iline][isample] = 1;
316 *Resampled = resampled_tmp;
317 *Resampled_mask = resampled_mask_tmp;
MTKt_status MtkDataBufferAllocate(int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer *databuf)
Allocate Data Buffer.
2-dimensional Data Buffer
float kernel(float d, float a)
#define MTKT_DATABUFFER_INIT
MTKt_status MtkDataBufferFree(MTKt_DataBuffer *databuf)
Free data buffer.
MTKt_status MtkResampleCubicConvolution(const MTKt_DataBuffer *Source, const MTKt_DataBuffer *Source_mask, const MTKt_DataBuffer *Line, const MTKt_DataBuffer *Sample, float A, MTKt_DataBuffer *Resampled, MTKt_DataBuffer *Resampled_mask)
Resample source data at the given coordinates using interpolation by cubic convolution.
#define MTK_ERR_CODE_MSG_JUMP(code, msg)
#define MTK_ERR_COND_JUMP(code)