本文整理汇总了C++中ImageView::nrows方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::nrows方法的具体用法?C++ ImageView::nrows怎么用?C++ ImageView::nrows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::nrows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
Image* resize(T& image, const Dim& dim, int resize_quality) {
typename T::data_type* data = new typename T::data_type
(dim, image.origin());
ImageView<typename T::data_type>* view =
new ImageView<typename T::data_type>(*data);
/*
Images with nrows or ncols == 1 cannot be scaled by VIGRA.
This is a hack that just returns an image with the same
color as the upper-left pixel
*/
if (image.nrows() <= 1 || image.ncols() <= 1 ||
view->nrows() <= 1 || view->ncols() <= 1) {
std::fill(view->vec_begin(), view->vec_end(), image.get(Point(0, 0)));
return view;
}
if (resize_quality == 0) {
// for straight scaling, resampleImage must be used in VIGRA
double xfactor = (double)view->ncols()/image.ncols();
double yfactor = (double)view->nrows()/image.nrows();
// this is implemented incorrectly in VIGRA:
//resizeImageNoInterpolation(src_image_range(image), dest_image_range(*view));
// the following works however:
// requires extension of VIGRA (see basicgeometry.hxx)
// that are not yet merged into VIGRA 1.6.0
resampleImage(src_image_range(image), dest_image(*view), xfactor, yfactor);
} else if (resize_quality == 1) {
resizeImageLinearInterpolation(src_image_range(image), dest_image_range(*view));
} else {
resizeImageSplineInterpolation(src_image_range(image), dest_image_range(*view));
}
image_copy_attributes(image, *view);
return view;
}