本文整理汇总了C++中ImageBuf::deep_samples方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageBuf::deep_samples方法的具体用法?C++ ImageBuf::deep_samples怎么用?C++ ImageBuf::deep_samples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageBuf
的用法示例。
在下文中一共展示了ImageBuf::deep_samples方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nonfinite_pixel_samp
//.........这里部分代码省略.........
printf ("%sStats FiniteCount: ", indent);
for (unsigned int i=0; i<stats.finitecount.size(); ++i) {
printf ("%llu ", (unsigned long long)stats.finitecount[i]);
}
printf ("\n");
if (input.deep()) {
const DeepData *dd (input.deepdata());
size_t npixels = dd->pixels();
size_t totalsamples = 0, emptypixels = 0;
size_t maxsamples = 0, minsamples = std::numeric_limits<size_t>::max();
size_t maxsamples_npixels = 0;
float mindepth = std::numeric_limits<float>::max();
float maxdepth = -std::numeric_limits<float>::max();
Imath::V3i maxsamples_pixel(-1,-1,-1), minsamples_pixel(-1,-1,-1);
Imath::V3i mindepth_pixel(-1,-1,-1), maxdepth_pixel(-1,-1,-1);
Imath::V3i nonfinite_pixel(-1,-1,-1);
int nonfinite_pixel_samp(-1), nonfinite_pixel_chan(-1);
size_t sampoffset = 0;
int nchannels = dd->channels();
int depthchannel = -1;
long long nonfinites = 0;
for (int c = 0; c < nchannels; ++c)
if (Strutil::iequals (originalspec.channelnames[c], "Z"))
depthchannel = c;
int xend = originalspec.x + originalspec.width;
int yend = originalspec.y + originalspec.height;
int zend = originalspec.z + originalspec.depth;
size_t p = 0;
std::vector<size_t> nsamples_histogram;
for (int z = originalspec.z; z < zend; ++z) {
for (int y = originalspec.y; y < yend; ++y) {
for (int x = originalspec.x; x < xend; ++x, ++p) {
size_t samples = input.deep_samples (x, y, z);
totalsamples += samples;
if (samples == maxsamples)
++maxsamples_npixels;
if (samples > maxsamples) {
maxsamples = samples;
maxsamples_pixel.setValue (x, y, z);
maxsamples_npixels = 1;
}
if (samples < minsamples)
minsamples = samples;
if (samples == 0)
++emptypixels;
if (samples >= nsamples_histogram.size())
nsamples_histogram.resize (samples+1, 0);
nsamples_histogram[samples] += 1;
for (unsigned int s = 0; s < samples; ++s) {
for (int c = 0; c < nchannels; ++c) {
float d = input.deep_value (x, y, z, c, s);
if (! isfinite(d)) {
if (nonfinites++ == 0) {
nonfinite_pixel.setValue (x, y, z);
nonfinite_pixel_samp = s;
nonfinite_pixel_chan = c;
}
}
if (depthchannel == c) {
if (d < mindepth) {
mindepth = d;
mindepth_pixel.setValue (x, y, z);
}
if (d > maxdepth) {
maxdepth = d;
示例2: if
bool
ImageBufAlgo::deepen (ImageBuf &dst, const ImageBuf &src, float zvalue,
ROI roi, int nthreads)
{
if (src.deep()) {
// For some reason, we were asked to deepen an already-deep image.
// So just copy it.
return dst.copy (src);
// FIXME: once paste works for deep files, this should really be
// return paste (dst, roi.xbegin, roi.ybegin, roi.zbegin, roi.chbegin,
// src, roi, nthreads);
}
// Construct an ideal spec for dst, which is like src but deep.
const ImageSpec &srcspec (src.spec());
int nc = srcspec.nchannels;
int zback_channel = -1;
ImageSpec force_spec = srcspec;
force_spec.deep = true;
force_spec.set_format (TypeDesc::FLOAT);
force_spec.channelformats.clear();
for (int c = 0; c < nc; ++c) {
if (force_spec.channelnames[c] == "Z")
force_spec.z_channel = c;
else if (force_spec.channelnames[c] == "Zback")
zback_channel = c;
}
bool add_z_channel = (force_spec.z_channel < 0);
if (add_z_channel) {
// No z channel? Make one.
force_spec.z_channel = force_spec.nchannels++;
force_spec.channelnames.push_back ("Z");
}
if (! IBAprep (roi, &dst, &src, NULL, &force_spec, IBAprep_SUPPORT_DEEP))
return false;
if (! dst.deep()) {
dst.error ("Cannot deepen to a flat image");
return false;
}
float *pixel = OIIO_ALLOCA (float, nc);
// First, figure out which pixels get a sample and which do not
for (int z = roi.zbegin; z < roi.zend; ++z)
for (int y = roi.ybegin; y < roi.yend; ++y)
for (int x = roi.xbegin; x < roi.xend; ++x) {
bool has_sample = false;
src.getpixel (x, y, z, pixel);
for (int c = 0; c < nc; ++c)
if (c != force_spec.z_channel && c != zback_channel
&& pixel[c] != 0.0f) {
has_sample = true;
break;
}
if (! has_sample && ! add_z_channel)
for (int c = 0; c < nc; ++c)
if ((c == force_spec.z_channel || c == zback_channel)
&& (pixel[c] != 0.0f && pixel[c] < 1e30)) {
has_sample = true;
break;
}
if (has_sample)
dst.set_deep_samples (x, y, z, 1);
}
dst.deep_alloc ();
// Now actually set the values
for (int z = roi.zbegin; z < roi.zend; ++z)
for (int y = roi.ybegin; y < roi.yend; ++y)
for (int x = roi.xbegin; x < roi.xend; ++x) {
if (dst.deep_samples (x, y, z) == 0)
continue;
for (int c = 0; c < nc; ++c)
dst.set_deep_value (x, y, z, c, 0 /*sample*/,
src.getchannel (x, y, z, c));
if (add_z_channel)
dst.set_deep_value (x, y, z, nc, 0, zvalue);
}
bool ok = true;
// FIXME -- the above doesn't split into threads. Someday, it should
// be refactored like this:
// OIIO_DISPATCH_COMMON_TYPES2 (ok, "deepen", deepen_,
// dst.spec().format, srcspec.format,
// dst, src, add_z_channel, z, roi, nthreads);
return ok;
}