当前位置: 首页>>代码示例>>C++>>正文


C++ ImageType::height方法代码示例

本文整理汇总了C++中ImageType::height方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageType::height方法的具体用法?C++ ImageType::height怎么用?C++ ImageType::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageType的用法示例。


在下文中一共展示了ImageType::height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: img

std::unique_ptr<Image<OpenCVColorType>> OpenCVImageDenoiser::denoise(const ImageType& image) const
{
	cv::Mat img(image.height(), image.width(), CV_8UC3);
	for (int i = 0; i < img.rows; ++i)
		for (int j = 0; j < img.cols; ++j)
			img.at<cv::Vec3b>(i, j) = image[{i, j}];
//	cv::cvtColor(img, img, CV_BGR2GRAY);
	cv::Mat res(img.rows, img.cols, CV_8UC3);
	cv::fastNlMeansDenoisingColored(img, res);
	return std::make_unique<OpenCVImage>(res);
}
开发者ID:NightCodersss,项目名称:obtuse-waffle,代码行数:11,代码来源:opencv_image_denoiser.cpp

示例2: Load

void Texture::Load(const std::string& filename, bool mipmap/* = false*/)
{
    if (m_opengl_id)
        Clear();

#if GG_USE_DEVIL_IMAGE_LOAD_LIBRARY

    InitDevIL();

    ILuint id, error;
    ilGenImages(1, &id);
    CheckILErrors("ilGenImages(1, &id)");
    ilBindImage(id);
    CheckILErrors("ilBindImage(id)");
    ilLoadImage(const_cast<char*>(filename.c_str()));
    if ((error = ilGetError()) != IL_NO_ERROR) {
        std::string call = "ilLoadImage(\"" + filename + "\")";
        if (VERBOSE_DEVIL_ERROR_REPORTING) {
            std::cerr << "IL call \"" << call << "\" failed with IL error \"" << iluErrorString(error)
                      << "\" (code " << error << ")\n";
        }
        CheckILErrors(call);
        throw BadFile("Could not load temporary DevIL image from file \"" + filename + "\"");
    }

    m_filename = filename;
    m_default_width = X(ilGetInteger(IL_IMAGE_WIDTH));
    CheckILErrors("ilGetInteger(IL_IMAGE_WIDTH)");
    m_default_height = Y(ilGetInteger(IL_IMAGE_HEIGHT));
    CheckILErrors("ilGetInteger(IL_IMAGE_HEIGHT)");
    m_bytes_pp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
    CheckILErrors("ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL)");
    m_format = ilGetInteger(IL_IMAGE_FORMAT);
    CheckILErrors("ilGetInteger(IL_IMAGE_FORMAT)");
    if (m_format == IL_COLOR_INDEX) {
        m_format = IL_RGBA;
        m_type = IL_UNSIGNED_BYTE;
        m_bytes_pp = 4;
        ilConvertImage(m_format, m_type);
        CheckILErrors("ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE)");
    } else {
        m_type = ilGetInteger(IL_IMAGE_TYPE);
        CheckILErrors("ilGetInteger(IL_IMAGE_TYPE)");
    }
    ILubyte* image_data = ilGetData();
    CheckILErrors("ilGetData()");
    Init(m_default_width, m_default_height, image_data, m_format, m_type, m_bytes_pp, mipmap);

    ilDeleteImages(1, &id);
    CheckILErrors("ilDeleteImages(1, &id)");

#else

    namespace gil = boost::gil;
    namespace fs = boost::filesystem;

    BOOST_STATIC_ASSERT((sizeof(gil::gray8_pixel_t) == 1));
    BOOST_STATIC_ASSERT((sizeof(gil::gray_alpha8_pixel_t) == 2));
    BOOST_STATIC_ASSERT((sizeof(gil::rgb8_pixel_t) == 3));
    BOOST_STATIC_ASSERT((sizeof(gil::rgba8_pixel_t) == 4));

    typedef boost::mpl::vector4<
        gil::gray8_image_t,
        gil::gray_alpha8_image_t,
        gil::rgb8_image_t,
        gil::rgba8_image_t
    > ImageTypes;
    typedef gil::any_image<ImageTypes> ImageType;

    fs::path path(filename);

    if (!fs::exists(path))
        throw BadFile("Texture file \"" + filename + "\" does not exist");

    if (!fs::is_regular_file(path))
        throw BadFile("Texture \"file\" \"" + filename + "\" is not a file");

    std::string extension = boost::algorithm::to_lower_copy(path.extension().string());

    ImageType image;
    try {
        // First attempt -- try just to read the file in one of the default
        // formats above.
#if GG_HAVE_LIBJPEG
        if (extension == ".jpg" || extension == ".jpe" || extension == ".jpeg")
            gil::jpeg_read_image(filename, image);
        else
#endif
#if GG_HAVE_LIBPNG
        if (extension == ".png")
            gil::png_read_image(filename, image);
        else
#endif
#if GG_HAVE_LIBTIFF
        if (extension == ".tif" || extension == ".tiff")
            gil::tiff_read_image(filename, image);
        else
#endif
            throw BadFile("Texture file \"" + filename + "\" does not have a supported file extension");
    } catch (const std::ios_base::failure &) {
//.........这里部分代码省略.........
开发者ID:luiges90,项目名称:freeorion,代码行数:101,代码来源:Texture.cpp


注:本文中的ImageType::height方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。