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


C++ SrcView::xy_at方法代码示例

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


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

示例1: gradient

static float gradient(const SrcView& src, const point_t& point, Color channel) {
	point_t pR, pL, pU, pD;

	if (point.x == 0)
		pL = point_t(0, 0);
	else
		pL = point_t(-1, 0);

	if (point.y == 0)
		pD = point_t(0, 0);
	else
		pD = point_t(0, -1);

	auto xRight = src.xy_at(point + point_t(1, 0));
	auto xLeft = src.xy_at(point + pL);

	auto yUp = src.xy_at(point + point_t(0, 1));
	auto yDown = src.xy_at(point + pD);

	auto xx = fabs(get_color(*xRight, channel) - get_color(*xLeft, channel));
	auto yy = fabs(get_color(*yUp, channel) - get_color(*yDown, channel));

	return sqrt((powf(xx, 2) + powf(yy, 2)));
}
开发者ID:GHamrouni,项目名称:ImageAbstractions,代码行数:24,代码来源:Gradient.hpp

示例2: sample

bool sample(bilinear_sampler, const SrcView& src, const point2<F>& p, DstP& result) {
    typedef typename SrcView::value_type SrcP;
    ///modif
    point2<std::ptrdiff_t> p0(ifloor(p)); // the closest integer coordinate top left from p
    point2<F> frac(p.x-p0.x, p.y-p0.y);
    if (p0.x < 0 || p0.y < 0 || p0.x>=src.width() || p0.y>=src.height()) return false;

    pixel<F,devicen_layout_t<num_channels<SrcView>::value> > mp(0);                     // suboptimal
    typename SrcView::xy_locator loc=src.xy_at(p0.x,p0.y);

    if (p0.x+1<src.width()) {
        if (p0.y+1<src.height()) {
            // most common case - inside the image, not on the last row or column
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(*loc,      (1-frac.x)*(1-frac.y),mp);
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(loc.x()[1],   frac.x *(1-frac.y),mp);
            ++loc.y();
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(*loc,      (1-frac.x)*   frac.y ,mp);
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(loc.x()[1],   frac.x *   frac.y ,mp);
        } else {
            // on the last row, but not the bottom-right corner pixel
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(*loc,      (1-frac.x),mp);
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(loc.x()[1],   frac.x ,mp);
        }
    } else {
        if (p0.y+1<src.height()) {
            // on the last column, but not the bottom-right corner pixel
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(*loc,      (1-frac.y),mp);
            ++loc.y();
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(*loc,         frac.y ,mp);
        } else {
            // the bottom-right corner pixel
            detail::add_dst_mul_src<SrcP,F,pixel<F,devicen_layout_t<num_channels<SrcView>::value> > >()(*loc,1,mp);
        }
    }

    // Convert from floating point average value to the source type
    SrcP src_result;
    cast_pixel(mp,src_result);

    color_convert(src_result, result);
    return true;
}
开发者ID:myirci,项目名称:gilviewer,代码行数:42,代码来源:sampler.hpp


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