本文整理汇总了C++中ImageBuf::interppixel方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageBuf::interppixel方法的具体用法?C++ ImageBuf::interppixel怎么用?C++ ImageBuf::interppixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageBuf
的用法示例。
在下文中一共展示了ImageBuf::interppixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ALLOCA
static bool
resample_ (ImageBuf &dst, const ImageBuf &src, bool interpolate,
ROI roi, int nthreads)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Lots of pixels and request for multi threads? Parallelize.
ImageBufAlgo::parallel_image (
boost::bind(resample_<DSTTYPE,SRCTYPE>, boost::ref(dst),
boost::cref(src), interpolate,
_1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
// Serial case
const ImageSpec &srcspec (src.spec());
const ImageSpec &dstspec (dst.spec());
int nchannels = src.nchannels();
// Local copies of the source image window, converted to float
float srcfx = srcspec.full_x;
float srcfy = srcspec.full_y;
float srcfw = srcspec.full_width;
float srcfh = srcspec.full_height;
float dstfx = dstspec.full_x;
float dstfy = dstspec.full_y;
float dstfw = dstspec.full_width;
float dstfh = dstspec.full_height;
float dstpixelwidth = 1.0f / dstfw;
float dstpixelheight = 1.0f / dstfh;
float *pel = ALLOCA (float, nchannels);
ImageBuf::Iterator<DSTTYPE> out (dst, roi);
ImageBuf::ConstIterator<SRCTYPE> srcpel (src);
for (int y = roi.ybegin; y < roi.yend; ++y) {
// s,t are NDC space
float t = (y-dstfy+0.5f)*dstpixelheight;
// src_xf, src_xf are image space float coordinates
float src_yf = srcfy + t * srcfh - 0.5f;
// src_x, src_y are image space integer coordinates of the floor
int src_y;
(void) floorfrac (src_yf, &src_y);
for (int x = roi.xbegin; x < roi.xend; ++x) {
float s = (x-dstfx+0.5f)*dstpixelwidth;
float src_xf = srcfx + s * srcfw - 0.5f;
int src_x;
(void) floorfrac (src_xf, &src_x);
if (interpolate) {
src.interppixel (src_xf, src_yf, pel);
for (int c = roi.chbegin; c < roi.chend; ++c)
out[c] = pel[c];
} else {
srcpel.pos (src_x, src_y, 0);
for (int c = roi.chbegin; c < roi.chend; ++c)
out[c] = srcpel[c];
}
++out;
}
}
return true;
}