本文整理汇总了C++中imagebuf::Iterator::done方法的典型用法代码示例。如果您正苦于以下问题:C++ Iterator::done方法的具体用法?C++ Iterator::done怎么用?C++ Iterator::done使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagebuf::Iterator
的用法示例。
在下文中一共展示了Iterator::done方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
static bool
clamp_ (ImageBuf &dst, const ImageBuf &src,
const float *min, const float *max,
bool clampalpha01, ROI roi, int nthreads)
{
ImageBufAlgo::parallel_image (roi, nthreads, [&](ROI roi){
ImageBuf::ConstIterator<S> s (src, roi);
for (ImageBuf::Iterator<D> d (dst, roi); ! d.done(); ++d, ++s) {
for (int c = roi.chbegin; c < roi.chend; ++c)
d[c] = OIIO::clamp<float> (s[c], min[c], max[c]);
}
int a = src.spec().alpha_channel;
if (clampalpha01 && a >= roi.chbegin && a < roi.chend) {
for (ImageBuf::Iterator<D> d (dst, roi); ! d.done(); ++d)
d[a] = OIIO::clamp<float> (d[a], 0.0f, 1.0f);
}
});
return true;
}
示例2: s
static bool
flop_ (ImageBuf &dst, const ImageBuf &src, ROI roi, int nthreads)
{
ImageBuf::ConstIterator<S, D> s (src, roi);
ImageBuf::Iterator<D, D> d (dst, roi);
for ( ; ! d.done(); ++d) {
s.pos (roi.xend-1 - (d.x() - roi.xbegin), d.y(), d.z());
for (int c = roi.chbegin; c < roi.chend; ++c)
d[c] = s[c];
}
return true;
}
示例3: a
static bool
pow_impl (ImageBuf &R, const ImageBuf &A, const float *b,
ROI roi, int nthreads)
{
ImageBufAlgo::parallel_image (roi, nthreads, [&](ROI roi){
ImageBuf::ConstIterator<Atype> a (A, roi);
for (ImageBuf::Iterator<Rtype> r (R, roi); !r.done(); ++r, ++a)
for (int c = roi.chbegin; c < roi.chend; ++c)
r[c] = pow (a[c], b[c]);
});
return true;
}
示例4: r
static bool
absdiff_impl (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
ROI roi, int nthreads)
{
ImageBufAlgo::parallel_image (roi, nthreads, [&](ROI roi){
ImageBuf::Iterator<Rtype> r (R, roi);
ImageBuf::ConstIterator<Atype> a (A, roi);
ImageBuf::ConstIterator<Btype> b (B, roi);
for ( ; !r.done(); ++r, ++a, ++b)
for (int c = roi.chbegin; c < roi.chend; ++c)
r[c] = std::abs (a[c] - b[c]);
});
return true;
}
示例5: s
static bool
flip_ (ImageBuf &dst, const ImageBuf &src, ROI dst_roi, int nthreads)
{
ROI src_roi_full = src.roi_full();
ROI dst_roi_full = dst.roi_full();
ImageBuf::ConstIterator<S, D> s (src);
ImageBuf::Iterator<D, D> d (dst, dst_roi);
for ( ; ! d.done(); ++d) {
int yy = d.y() - dst_roi_full.ybegin;
s.pos (d.x(), src_roi_full.yend-1 - yy, d.z());
for (int c = dst_roi.chbegin; c < dst_roi.chend; ++c)
d[c] = s[c];
}
return true;
}
示例6: d
static bool
channel_sum_ (ImageBuf &dst, const ImageBuf &src,
const float *weights, ROI roi, int nthreads)
{
ImageBufAlgo::parallel_image (roi, nthreads, [&](ROI roi){
ImageBuf::Iterator<D> d (dst, roi);
ImageBuf::ConstIterator<S> s (src, roi);
for ( ; !d.done(); ++d, ++s) {
float sum = 0.0f;
for (int c = roi.chbegin; c < roi.chend; ++c)
sum += s[c] * weights[c];
d[0] = sum;
}
});
return true;
}
示例7: ALLOCA
static bool
convolve_ (ImageBuf &dst, const ImageBuf &src, const ImageBuf &kernel,
bool normalize, ROI roi, int nthreads)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Lots of pixels and request for multi threads? Parallelize.
ImageBufAlgo::parallel_image (
boost::bind(convolve_<DSTTYPE,SRCTYPE>, boost::ref(dst),
boost::cref(src), boost::cref(kernel), normalize,
_1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
// Serial case
float scale = 1.0f;
if (normalize) {
scale = 0.0f;
for (ImageBuf::ConstIterator<float> k (kernel); ! k.done(); ++k)
scale += k[0];
scale = 1.0f / scale;
}
float *sum = ALLOCA (float, roi.chend);
ROI kroi = get_roi (kernel.spec());
ImageBuf::Iterator<DSTTYPE> d (dst, roi);
ImageBuf::ConstIterator<SRCTYPE> s (src, roi, ImageBuf::WrapClamp);
for ( ; ! d.done(); ++d) {
for (int c = roi.chbegin; c < roi.chend; ++c)
sum[c] = 0.0f;
for (ImageBuf::ConstIterator<float> k (kernel, kroi); !k.done(); ++k) {
float kval = k[0];
s.pos (d.x() + k.x(), d.y() + k.y(), d.z() + k.z());
for (int c = roi.chbegin; c < roi.chend; ++c)
sum[c] += kval * s[c];
}
for (int c = roi.chbegin; c < roi.chend; ++c)
d[c] = scale * sum[c];
}
return true;
}
示例8: r
static bool
mul_impl (ImageBuf &R, const float *val, ROI roi, int nthreads)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Possible multiple thread case -- recurse via parallel_image
ImageBufAlgo::parallel_image (
boost::bind(mul_impl<Rtype>, boost::ref(R), val,
_1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
ImageBuf::Iterator<Rtype> r (R, roi);
for (ImageBuf::Iterator<Rtype> r (R, roi); !r.done(); ++r)
for (int c = roi.chbegin; c < roi.chend; ++c)
r[c] = r[c] * val[c];
return true;
}
示例9:
static bool
fill_const_ (ImageBuf &dst, const float *values, ROI roi=ROI(), int nthreads=1)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Lots of pixels and request for multi threads? Parallelize.
ImageBufAlgo::parallel_image (
OIIO::bind(fill_const_<T>, OIIO::ref(dst), values,
_1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
// Serial case
for (ImageBuf::Iterator<T> p (dst, roi); !p.done(); ++p)
for (int c = roi.chbegin; c < roi.chend; ++c)
p[c] = values[c];
return true;
}
示例10: a
static bool
pow_impl (ImageBuf &R, const ImageBuf &A, const float *b,
ROI roi, int nthreads)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Possible multiple thread case -- recurse via parallel_image
ImageBufAlgo::parallel_image (
boost::bind(pow_impl<Rtype,Atype>, boost::ref(R), boost::cref(A), b,
_1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
ImageBuf::ConstIterator<Atype> a (A, roi);
for (ImageBuf::Iterator<Rtype> r (R, roi); !r.done(); ++r, ++a)
for (int c = roi.chbegin; c < roi.chend; ++c)
r[c] = pow (a[c], b[c]);
return true;
}
示例11: test_paste
void test_paste ()
{
std::cout << "test paste\n";
// Create the source image, make it a gradient
ImageSpec Aspec (4, 4, 3, TypeDesc::FLOAT);
ImageBuf A (Aspec);
for (ImageBuf::Iterator<float> it (A); !it.done(); ++it) {
it[0] = float(it.x()) / float(Aspec.width-1);
it[1] = float(it.y()) / float(Aspec.height-1);
it[2] = 0.1f;
}
// Create destination image -- black it out
ImageSpec Bspec (8, 8, 3, TypeDesc::FLOAT);
ImageBuf B (Bspec);
float gray[3] = { .1, .1, .1 };
ImageBufAlgo::fill (B, gray);
// Paste a few pixels from A into B -- include offsets
ImageBufAlgo::paste (B, 2, 2, 0, 1 /* chan offset */,
A, ROI(1, 4, 1, 4));
// Spot check
float a[3], b[3];
B.getpixel (1, 1, 0, b);
OIIO_CHECK_EQUAL (b[0], gray[0]);
OIIO_CHECK_EQUAL (b[1], gray[1]);
OIIO_CHECK_EQUAL (b[2], gray[2]);
B.getpixel (2, 2, 0, b);
A.getpixel (1, 1, 0, a);
OIIO_CHECK_EQUAL (b[0], gray[0]);
OIIO_CHECK_EQUAL (b[1], a[0]);
OIIO_CHECK_EQUAL (b[2], a[1]);
B.getpixel (3, 4, 0, b);
A.getpixel (2, 3, 0, a);
OIIO_CHECK_EQUAL (b[0], gray[0]);
OIIO_CHECK_EQUAL (b[1], a[0]);
OIIO_CHECK_EQUAL (b[2], a[1]);
}
示例12: B
static int
action_sub (int argc, const char *argv[])
{
if (ot.postpone_callback (2, action_sub, argc, argv))
return 0;
ImageRecRef B (ot.pop());
ImageRecRef A (ot.pop());
ot.read (A);
ot.read (B);
ot.push (new ImageRec (*A, ot.allsubimages ? -1 : 0,
ot.allsubimages ? -1 : 0, true, false));
int subimages = ot.curimg->subimages();
for (int s = 0; s < subimages; ++s) {
int miplevels = ot.curimg->miplevels(s);
for (int m = 0; m < miplevels; ++m) {
const ImageBuf &Aib ((*A)(s,m));
const ImageBuf &Bib ((*B)(s,m));
if (! same_size (Aib, Bib)) {
// FIXME: some day, there should be options of combining
// differing images somehow.
std::cerr << "oiiotool: " << argv[0] << " could not combine images of differing sizes\n";
continue;
}
ImageBuf &Rib ((*ot.curimg)(s,m));
ImageBuf::ConstIterator<float> a (Aib);
ImageBuf::ConstIterator<float> b (Bib);
ImageBuf::Iterator<float> r (Rib);
int nchans = Rib.nchannels();
for ( ; ! r.done(); ++r) {
a.pos (r.x(), r.y());
b.pos (r.x(), r.y());
for (int c = 0; c < nchans; ++c)
r[c] = a[c] - b[c];
}
}
}
return 0;
}
示例13: ImageSpec
bool
ImageBufAlgo::histogram_draw (ImageBuf &R,
const std::vector<imagesize_t> &histogram)
{
// Fail if there are no bins to draw.
int bins = histogram.size();
if (bins == 0) {
R.error ("There are no bins to draw, the histogram is empty");
return false;
}
// Check R and modify it if needed.
int height = R.spec().height;
if (R.spec().format != TypeDesc::TypeFloat || R.nchannels() != 1 ||
R.spec().width != bins) {
ImageSpec newspec = ImageSpec (bins, height, 1, TypeDesc::FLOAT);
R.reset ("dummy", newspec);
}
// Fill output image R with white color.
ImageBuf::Iterator<float, float> r (R);
for ( ; ! r.done(); ++r)
r[0] = 1;
// Draw histogram left->right, bottom->up.
imagesize_t max = *std::max_element (histogram.begin(), histogram.end());
for (int b = 0; b < bins; b++) {
int bin_height = (int) ((float)histogram[b]/(float)max*height + 0.5f);
if (bin_height != 0) {
// Draw one bin at column b.
for (int j = 1; j <= bin_height; j++) {
int row = height - j;
r.pos (b, row);
r[0] = 0;
}
}
}
return true;
}
示例14: r
static bool
mad_implf (ImageBuf &R, const ImageBuf &A, const float *b, const float *c,
ROI roi, int nthreads)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Possible multiple thread case -- recurse via parallel_image
ImageBufAlgo::parallel_image (
boost::bind(mad_implf<Rtype,Atype>, boost::ref(R),
boost::cref(A), b, c,
_1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
// Serial case
ImageBuf::Iterator<Rtype> r (R, roi);
ImageBuf::ConstIterator<Atype> a (A, roi);
for ( ; !r.done(); ++r, ++a)
for (int ch = roi.chbegin; ch < roi.chend; ++ch)
r[ch] = a[ch] * b[ch] + c[ch];
return true;
}
示例15: lerp
static bool
fill_tb_ (ImageBuf &dst, const float *top, const float *bottom,
ROI origroi, ROI roi=ROI(), int nthreads=1)
{
if (nthreads != 1 && roi.npixels() >= 1000) {
// Lots of pixels and request for multi threads? Parallelize.
ImageBufAlgo::parallel_image (
OIIO::bind(fill_tb_<T>, OIIO::ref(dst), top, bottom,
origroi, _1 /*roi*/, 1 /*nthreads*/),
roi, nthreads);
return true;
}
// Serial case
float h = std::max (1, origroi.height() - 1);
for (ImageBuf::Iterator<T> p (dst, roi); !p.done(); ++p) {
float v = (p.y() - origroi.ybegin) / h;
for (int c = roi.chbegin; c < roi.chend; ++c)
p[c] = lerp (top[c], bottom[c], v);
}
return true;
}