本文整理汇总了C++中ImageBuf::subimage方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageBuf::subimage方法的具体用法?C++ ImageBuf::subimage怎么用?C++ ImageBuf::subimage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageBuf
的用法示例。
在下文中一共展示了ImageBuf::subimage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static bool
read_input (const std::string &filename, ImageBuf &img,
int subimage=0, int miplevel=0)
{
if (img.subimage() >= 0 && img.subimage() == subimage)
return true;
if (img.init_spec (filename, subimage, miplevel) &&
img.read (subimage, miplevel, false, TypeDesc::FLOAT))
return true;
return false;
}
示例2:
static bool
read_input (const std::string &filename, ImageBuf &img,
int subimage=0, int miplevel=0)
{
if (img.subimage() >= 0 && img.subimage() == subimage)
return true;
if (img.init_spec (filename, subimage, miplevel) &&
img.read (subimage, miplevel, false, TypeDesc::FLOAT))
return true;
std::cerr << "oiiotool ERROR: Could not read " << filename << ":\n\t"
<< img.geterror() << "\n";
return false;
}
示例3:
static bool
read_input (const std::string &filename, ImageBuf &img,
ImageCache *cache, int subimage=0, int miplevel=0)
{
if (img.subimage() >= 0 &&
img.subimage() == subimage && img.miplevel() == miplevel)
return true;
img.reset (filename, cache);
if (img.read (subimage, miplevel, false, TypeDesc::TypeFloat))
return true;
std::cerr << "idiff ERROR: Could not read " << filename << ":\n\t"
<< img.geterror() << "\n";
return false;
}
示例4:
static bool
read_input (const std::string &filename, ImageBuf &img,
int subimage=0, int miplevel=0)
{
if (img.subimage() >= 0 && img.subimage() == subimage)
return true;
if (img.init_spec (filename, subimage, miplevel)) {
// Force a read now for reasonable-sized first images in the
// file. This can greatly speed up the multithread case for
// tiled images by not having multiple threads working on the
// same image lock against each other on the file handle.
// We guess that "reasonable size" is 200 MB, that's enough to
// hold a 4k RGBA float image. Larger things will
// simply fall back on ImageCache.
bool forceread = (img.spec().image_bytes() < 200*1024*1024);
return img.read (subimage, miplevel, forceread, TypeDesc::FLOAT);
}
return false;
}
示例5: DASSERT
IplImage *
ImageBufAlgo::to_IplImage (const ImageBuf &src)
{
#ifdef USE_OPENCV
ImageBuf tmp = src;
ImageSpec spec = tmp.spec();
// Make sure the image buffer is initialized.
if (!tmp.initialized() && !tmp.read(tmp.subimage(), tmp.miplevel(), true)) {
DASSERT (0 && "Could not initialize ImageBuf.");
return NULL;
}
int dstFormat;
TypeDesc dstSpecFormat;
if (spec.format == TypeDesc(TypeDesc::UINT8)) {
dstFormat = IPL_DEPTH_8U;
dstSpecFormat = spec.format;
} else if (spec.format == TypeDesc(TypeDesc::INT8)) {
dstFormat = IPL_DEPTH_8S;
dstSpecFormat = spec.format;
} else if (spec.format == TypeDesc(TypeDesc::UINT16)) {
dstFormat = IPL_DEPTH_16U;
dstSpecFormat = spec.format;
} else if (spec.format == TypeDesc(TypeDesc::INT16)) {
dstFormat = IPL_DEPTH_16S;
dstSpecFormat = spec.format;
} else if (spec.format == TypeDesc(TypeDesc::HALF)) {
dstFormat = IPL_DEPTH_32F;
// OpenCV does not support half types. Switch to float instead.
dstSpecFormat = TypeDesc(TypeDesc::FLOAT);
} else if (spec.format == TypeDesc(TypeDesc::FLOAT)) {
dstFormat = IPL_DEPTH_32F;
dstSpecFormat = spec.format;
} else if (spec.format == TypeDesc(TypeDesc::DOUBLE)) {
dstFormat = IPL_DEPTH_64F;
dstSpecFormat = spec.format;
} else {
DASSERT (0 && "Unknown data format in ImageBuf.");
return NULL;
}
IplImage *ipl = cvCreateImage(cvSize(spec.width, spec.height), dstFormat, spec.nchannels);
if (!ipl) {
DASSERT (0 && "Unable to create IplImage.");
return NULL;
}
size_t pixelsize = dstSpecFormat.size() * spec.nchannels;
// Account for the origin in the line step size, to end up with the
// standard OIIO origin-at-upper-left:
size_t linestep = ipl->origin ? -ipl->widthStep : ipl->widthStep;
bool converted = convert_image(spec.nchannels, spec.width, spec.height, 1,
tmp.localpixels(), spec.format,
spec.pixel_bytes(), spec.scanline_bytes(), 0,
ipl->imageData, dstSpecFormat,
pixelsize, linestep, 0);
if (!converted) {
DASSERT (0 && "convert_image failed.");
cvReleaseImage(&ipl);
return NULL;
}
// OpenCV uses BGR ordering
if (spec.nchannels == 3) {
cvCvtColor(ipl, ipl, CV_RGB2BGR);
} else if (spec.nchannels == 4) {
cvCvtColor(ipl, ipl, CV_RGBA2BGRA);
}
return ipl;
#else
return NULL;
#endif
}