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


C++ SrcView类代码示例

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


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

示例1: sobel_xy

void sobel_xy(const SrcView& src, const DstView& dst) {
    typedef typename channel_type<DstView>::type dst_channel_t;

    int max_x = src.width() - 1;
    int width = src.width();
    for (int y=1; y<src.height()-1; ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=1; x < max_x; ++x) {
            for (int c=0; c< num_channels<rgb8_view_t>::value; ++c) {
            	dst_channel_t srcPlus1 = src_it[x+width][c]; //TODO should be replaced by line length
            	dst_channel_t srcMinus1 = src_it[x-width][c];
            	dst_channel_t sobelY = (srcPlus1 > srcMinus1) ?
            			srcPlus1 - srcMinus1 :
						srcMinus1 - srcPlus1;
            	srcPlus1 = src_it[x+1][c];
            	srcMinus1 = src_it[x-1][c];
            	dst_channel_t sobelX = (srcPlus1 > srcMinus1) ?
            			srcPlus1 - srcMinus1 :
						srcMinus1 - srcPlus1;
            	dst_it[x][c] = max(sobelX, sobelY);
            }
        }
    }
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:26,代码来源:GILOperation.cpp

示例2: blur

void blur(const SrcView& src, const DstView& dst) {
    typedef typename channel_type<DstView>::type dst_channel_t;

    int max_x = src.width() - 1;
    int width = src.width();
    for (int y=1; y<src.height()-1; ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=1; x < max_x; ++x) {
            for (int c=0; c< num_channels<rgb8_view_t>::value; ++c) {
            	dst_it[x][c] =
            		src_it[x-1-width][c] / 16 +
            		src_it[x-width][c] / 8 +
            		src_it[x-1-width][c] / 16 +

            		src_it[x-1][c] / 8 +
            		src_it[x][c] / 4 +
            		src_it[x-1][c] / 8 +

            		src_it[x-1+width][c] / 16 +
            		src_it[x+width][c] / 8 +
            		src_it[x-1+width][c] / 16;
            }
        }
    }
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:27,代码来源:GILOperation.cpp

示例3: runtime_error

inline void boost::gil::rescale_rows(const SrcView& src, const DstView& dst, const Filter& filter)
{
  typedef typename SrcView::value_type src_pixel_t;
  typedef typename gil::detail::create_accum_pixel_type<src_pixel_t>::type accum_pixel_t;

  if (src.width() != dst.width())
  {
    throw std::runtime_error("rescale_rows: width of source and destination views must match");
  }

  detail::weight_table weights;
  weights.reset(filter, src.height(), dst.height());

  detail::weight_table::const_iterator const table_begin = weights.begin();
  detail::weight_table::const_iterator const table_end   = weights.end();

  typedef typename DstView::coord_t coord_t;
  coord_t const width = dst.width();

  for (coord_t x=0; x<width; x++)
  {
    detail::rescale_line<accum_pixel_t>(
        src.col_begin(x)
      , dst.col_begin(x)
      , table_begin
      , table_end
      );
  }
}
开发者ID:apextw,项目名称:Ramen,代码行数:29,代码来源:rescale.hpp

示例4: sample

bool sample(nearest_neighbor_sampler, const SrcView& src, const point2<F>& p, DstP& result) {
    typename SrcView::point_t center(iround(p));
    if (center.x>=0 && center.y>=0 && center.x<src.width() && center.y<src.height()) {
        result=src(center.x,center.y);
        return true;
    }
    return false;
}
开发者ID:AlexMioMio,项目名称:boost,代码行数:8,代码来源:sampler.hpp

示例5: sample

bool sample(nearest_neighbor_sampler, const SrcView& src, const point2<F>& p, DstP& result) {
	///modif Adrien pour 64 bits : ptrdiff au lieu d'int
    point2<std::ptrdiff_t> center(iround(p));
    if (center.x>=0 && center.y>=0 && center.x<src.width() && center.y<src.height()) {
        result=src(center.x,center.y);
        return true;
    }
    return false;
}
开发者ID:myirci,项目名称:gilviewer,代码行数:9,代码来源:sampler.hpp

示例6: x_gradient

void x_gradient(const SrcView& src, const DstView& dst) {
    typedef typename channel_type<DstView>::type dst_channel_t;

    for (int y=0; y<src.height(); ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=1; x<src.width()-1; ++x)
            static_transform(src_it[x-1], src_it[x+1], dst_it[x], 
                               halfdiff_cast_channels<dst_channel_t>());
    }
}
开发者ID:aubonbeurre,项目名称:abbsandbox,代码行数:12,代码来源:imaging_utils.hpp

示例7:

inline void boost::gil::rescale(const SrcView& src, const DstView& dst, const Filter& filter)
{
  typedef typename SrcView::value_type src_pixel_t;
  typedef typename gil::detail::create_accum_pixel_type<src_pixel_t>::type accum_pixel_t;

  // construct weights tables

  detail::weight_table horizontal_weights;
  horizontal_weights.reset(filter, src.width(), dst.width());

  detail::weight_table vertical_weights;
  vertical_weights.reset(filter, src.height(), dst.height());

  // allocate intermediary pixels row

  std::vector<accum_pixel_t> intermediate_row( src.width() );

  typedef typename DstView::coord_t coord_t;
  coord_t const src_width  = src.width();
  coord_t const dst_height = dst.height();

  for (coord_t y=0; y<dst_height; y++)
  {
    // create the intermediate row by vertically sampling the source image pixels

    detail::weight_table::const_iterator const vtable_begin = vertical_weights.begin() + y;
    detail::weight_table::const_iterator const vtable_end   = vtable_begin + 1;

    for (coord_t x=0; x<src_width; x++)
    {
      detail::rescale_line<accum_pixel_t>(
          src.col_begin(x)
        , intermediate_row.begin() + x
        , vtable_begin
        , vtable_end
        );
    }

    // scale horizontally the intermediate row into the destination row

    detail::weight_table::const_iterator const htable_begin = horizontal_weights.begin();
    detail::weight_table::const_iterator const htable_end   = horizontal_weights.end();

    detail::rescale_line<accum_pixel_t>(
        intermediate_row.begin()
      , dst.row_begin(y)
      , htable_begin
      , htable_end
      );
  }
}
开发者ID:apextw,项目名称:Ramen,代码行数:51,代码来源:rescale.hpp

示例8: x_gradient

void x_gradient(const SrcView& src, const DstView& dst) {

    int max_x = src.width()-1;
    for (int y=0; y<src.height(); ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=1; x < max_x; ++x) {
            for (int c=0; c< num_channels<rgb8_view_t>::value; ++c) {
            	dst_it[x][c] = (src_it[x+1][c] - src_it[x-1][c])/2;
            }
        }
    }
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:14,代码来源:GILOperation.cpp

示例9: grayToRgbView

void grayToRgbView(const SrcView& src, const DstView& dst) {
    typedef typename channel_type<DstView>::type dst_channel_t;

    int width = src.width();
    for (int y=0; y< src.height(); ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=0; x < width; ++x) {
        	dst_channel_t grayValue = (dst_channel_t) src_it[x];
            for (int c=0; c< num_channels<rgb8_view_t>::value; ++c) {
            	dst_it[x][c] = grayValue;
            }
        }
    }
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:16,代码来源:GILOperation.cpp

示例10: rgbToGrayView

void rgbToGrayView(const SrcView& src, const DstView& dst) {
    typedef typename channel_type<DstView>::type dst_channel_t;

    int width = src.width();
    for (int y=0; y< src.height(); ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=0; x < width; ++x) {
        	int combination = 0;
            for (int c=0; c< num_channels<rgb8_view_t>::value; ++c) {
            	combination += src_it[x][c] * RGB_TO_GRAY_INT[c];
            }
        	dst_it[x] = (dst_channel_t) (combination / 100);
        }
    }
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:17,代码来源:GILOperation.cpp

示例11: view_multiplies_scalar

inline void view_multiplies_scalar(const SrcView& src,const Scalar& scalar,const DstView& dst) {
    BOOST_ASSERT(src.dimensions() == dst.dimensions());
    using PIXEL_SRC_REF = typename pixel_proxy<typename SrcView::value_type>::type;
    using PIXEL_DST_REF = typename pixel_proxy<typename DstView::value_type>::type;
    int height=src.height();
    for(int rr=0;rr<height;++rr) {
        typename SrcView::x_iterator it_src=src.row_begin(rr);
        typename DstView::x_iterator it_dst=dst.row_begin(rr);
        typename SrcView::x_iterator it_src_end=src.row_end(rr);
        while(it_src!=it_src_end) {
            pixel_assigns_t<PixelAccum,PIXEL_DST_REF>()(
                pixel_multiplies_scalar_t<PIXEL_SRC_REF,Scalar,PixelAccum>()(*it_src,scalar),
                *it_dst);
            ++it_src; ++it_dst;
        }
    }
}
开发者ID:boostorg,项目名称:gil,代码行数:17,代码来源:algorithm.hpp

示例12: sobel_x

void sobel_x(const SrcView& src, const DstView& dst) {
    typedef typename channel_type<DstView>::type dst_channel_t;

    int max_x = src.width()-1;
    for (int y=0; y<src.height(); ++y) {
        typename SrcView::x_iterator src_it = src.row_begin(y);
        typename DstView::x_iterator dst_it = dst.row_begin(y);

        for (int x=1; x < max_x; ++x) {
            for (int c=0; c< num_channels<rgb8_view_t>::value; ++c) {
            	dst_channel_t srcPlus1 = src_it[x+1][c];
            	dst_channel_t srcMinus1 = src_it[x-1][c];
            	dst_it[x][c] = (srcPlus1 > srcMinus1) ?
            			srcPlus1 - srcMinus1 :
						srcMinus1 - srcPlus1;
            }
        }
    }
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:19,代码来源:GILOperation.cpp

示例13: 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


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