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


C++ Mat_::size方法代码示例

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


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

示例1: cvToCloud

 inline void
 cvToCloud(const cv::Mat_<cv::Point3f>& points3d, pcl::PointCloud<PointT>& cloud, const cv::Mat& mask = cv::Mat())
 {
   cloud.clear();
   cloud.width = points3d.size().width;
   cloud.height = points3d.size().height;
   cv::Mat_<cv::Point3f>::const_iterator point_it = points3d.begin(), point_end = points3d.end();
   const bool has_mask = !mask.empty();
   cv::Mat_<uchar>::const_iterator mask_it;
   if (has_mask)
     mask_it = mask.begin<uchar>();
   for (; point_it != point_end; ++point_it, (has_mask ? ++mask_it : mask_it))
   {
     if (has_mask && !*mask_it)
       continue;
     cv::Point3f p = *point_it;
     if (p.x != p.x && p.y != p.y && p.z != p.z) //throw out NANs
       continue;
     PointT cp;
     cp.x = p.x;
     cp.y = p.y;
     cp.z = p.z;
     cloud.push_back(cp);
   }
 }
开发者ID:ethanrublee,项目名称:object_recognition,代码行数:25,代码来源:conversions.hpp

示例2: writeImageData

void writeImageData( ostream& os, const cv::Mat_<cv::Vec3b>& cimg, const cv::Mat_<cv::Vec3f>& points)
{
    const cv::Size imgSz = cimg.size();
    assert( imgSz == points.size());

    os << imgSz.height << " " << imgSz.width << endl;
    for ( int i = 0; i < imgSz.height; ++i)
    {
        const cv::Vec3f* pptr = points.ptr<cv::Vec3f>(i);
        const cv::Vec3b* cptr = cimg.ptr<cv::Vec3b>(i);
        for ( int j = 0; j < imgSz.width; ++j)
        {
            const cv::Vec3f& p = pptr[j];
            const cv::Vec3b& c = cptr[j];

            // Write the x,y,z
            os.write( (char*)&p[0], sizeof(float));
            os.write( (char*)&p[1], sizeof(float));
            os.write( (char*)&p[2], sizeof(float));

            // Write the colour
            os.write( (char*)&c[0], sizeof(byte));
            os.write( (char*)&c[1], sizeof(byte));
            os.write( (char*)&c[2], sizeof(byte));
        }   // end for - columns
    }   // end for - rows

    os << endl;
}   // end writeImageData
开发者ID:richeytastic,项目名称:rfeatures,代码行数:29,代码来源:View.cpp

示例3: subtractPlane

cv::Mat_<double> subtractPlane(cv::Mat_<double> phase, cv::Mat_<bool> mask){
    cv::Mat_<double> coeff(3,1);
    cv::Mat_<double> X(phase.rows * phase.cols,3);
    cv::Mat_<double> Z(phase.rows * phase.cols,1);
    int ndx = 0;
    for (int y = 0; y < phase.rows; ++y){
        for (int x = 0; x < phase.cols; ++x){
            if (mask(y,x)){
                Z(ndx) =  phase(y,x);
                X(ndx,0) = x;
                X(ndx,1) = y;
                X(ndx++,2) = 1.;
            }
        }
    }
    cv::solve(X,Z,coeff,CV_SVD);
    // plane generation, Z = Ax + By + C
    // distance calculation d = Ax + By - z + C / sqrt(A^2 + B^2 + C^2)
qDebug() << "plane coeffs" << coeff(0) << coeff(1) << coeff(2);

    cv::Mat_<double> newPhase(phase.size());
    for (int y = 0; y < phase.rows; ++y){
        for (int x = 0; x  < phase.cols; ++x){
            int b = (int)mask(y,x);
            if (b == 0 ){
                continue;
            }

            double val = x * coeff(0) + y * coeff(1) + coeff(2) - phase(y,x);
            double z = val/sqrt(coeff(0) * coeff(0) + coeff(1) * coeff(1) + 1);
            newPhase(y,x) = z;
        }
    }
    return newPhase;
}
开发者ID:musgravehill,项目名称:DFTFringe,代码行数:35,代码来源:dftarea.cpp

示例4: ComputeBrightnessTensor

cv::Mat ComputeBrightnessTensor(const cv::Mat_<double> &i1, const cv::Mat_<double> &i2, double hx, double hy){

  // compute derivatives
  cv::Mat x, y, t, kernel, middle;
  t = i2 - i1;
  middle = 0.5 * i1 + 0.5 * i2;

  kernel = (cv::Mat_<double>(1,5) << 1, -8, 0, 8, -1);
  cv::filter2D(middle, x, -1, kernel * 1.0/(12*hx), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);

  kernel = (cv::Mat_<double>(5,1) << 1, -8, 0, 8, -1);
  cv::filter2D(middle, y, -1, kernel * 1.0/(12*hy), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);

  // compute tensor
  // channel 0=J11, 1=J22, 2=J33, 3=J12, 4=J13, 5=J23
  cv::Mat_<cv::Vec6d> b(i1.size());
  for (int i = 0; i < i1.rows; i++){
    for (int j = 0; j < i1.cols; j++){
      b(i,j)[0] = x.at<double>(i,j) * x.at<double>(i,j);
      b(i,j)[1] = y.at<double>(i,j) * y.at<double>(i,j);
      b(i,j)[2] = t.at<double>(i,j) * t.at<double>(i,j);
      b(i,j)[3] = x.at<double>(i,j) * y.at<double>(i,j);
      b(i,j)[4] = x.at<double>(i,j) * t.at<double>(i,j);
      b(i,j)[5] = y.at<double>(i,j) * t.at<double>(i,j);

    }
  }

  return b;
}
开发者ID:V-Italy,项目名称:optical_flow,代码行数:30,代码来源:tensor_computation.cpp

示例5: erodeFB

// erode foreground and background regions to increase the size of unknown region
static void erodeFB(cv::Mat_<uchar> &trimap, int r)
{
    int w = trimap.cols;
    int h = trimap.rows;

    cv::Mat_<uchar> foreground(trimap.size(), (uchar)0);
    cv::Mat_<uchar> background(trimap.size(), (uchar)0);

    for (int y = 0; y < h; ++y)
        for (int x = 0; x < w; ++x)
        {
            if (trimap(y, x) == 0)
                background(y, x) = 1;
            else if (trimap(y, x) == 255)
                foreground(y, x) = 1;
        }


    cv::Mat kernel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(r, r));

    cv::erode(background, background, kernel);
    cv::erode(foreground, foreground, kernel);

    for (int y = 0; y < h; ++y)
        for (int x = 0; x < w; ++x)
        {
            if (background(y, x) == 0 && foreground(y, x) == 0)
                trimap(y, x) = 128;
        }
}
开发者ID:pfShawn,项目名称:global-matting,代码行数:31,代码来源:globalmatting.cpp

示例6: test_with_args

cv::Mat test_with_args(const cv::Mat_<float>& in, const int& var1 = 1,
const double& var2 = 10.0, const std::string& name=std::string("test_name")) {
    std::cerr << "in: " << in << std::endl;
    std::cerr << "sz: " << in.size() << std::endl;
    std::cerr << "Returning transpose" << std::endl;
    return in.t();
}
开发者ID:chakkritte,项目名称:numpy-opencv-converter,代码行数:7,代码来源:np_opencv_module.cpp

示例7:

WTLF::Cluster::Cluster(const cv::Mat_<float> &img, cv::Point start)
{
	// actually find the cluster
	WTLF::Cluster::FloodFillScratchpad scratch;
	scratch.img = img;
	scratch.marking.create(img.size());
	scratch.marking.setTo(0);
	maxDepth = 0;
	deepest = start;
	offset = start;
	scratch.br = start;
#ifdef FLOOD_FILL_DFS
	scratch.depth = 0;
#endif

	// need to use BFS due to stack overflow!
	// note that the deepest is just the last point visited!
	scratch.q.push(start);
	while (!scratch.q.empty())
	{
		floodFill(scratch.q.front(), &scratch);
		scratch.q.pop();
	}

	mat = scratch.marking(
		Rect(offset, scratch.br));
	deepest -= offset;
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:28,代码来源:WalkTheLineFitter.cpp

示例8: result

cv::Mat_<cv::Vec3b> getWrongColorSegmentationImage(cv::Mat_<int>& labels, int labelcount)
{
	std::vector<cv::Vec3b> colors;
	colors.reserve(labelcount);

	std::srand(0);

	for(int i = 0; i < labelcount; ++i)
	{
		cv::Vec3b ccolor;
		ccolor[0] = std::rand() % 256;
		ccolor[1] = std::rand() % 256;
		ccolor[2] = std::rand() % 256;
		colors.push_back(ccolor);
	}

	cv::Mat result(labels.size(), CV_8UC3);

	cv::Vec3b *dst_ptr = result.ptr<cv::Vec3b>(0);
	int *src_ptr = labels[0];

	for(std::size_t i = 0; i < labels.total(); ++i)
	{
		int label = *src_ptr++;
		assert(label < (int)colors.size());
		*dst_ptr++ = colors[label];
	}
	return result;
}
开发者ID:klindworth,项目名称:disparity_estimation,代码行数:29,代码来源:segmentation.cpp

示例9:

EDTFeature::EDTFeature( const cv::Mat_<byte> img, const cv::Size fvDims)
    : RFeatures::FeatureOperator( img.size(), fvDims)
{
    const cv::Mat_<int> sedt = RFeatures::DistanceTransform::calcdt( img);   // Distance map to edges
    cv::Mat fsedt;  // convert to 64 bit float for sqrt
    sedt.convertTo( fsedt, CV_64F);
    cv::sqrt( fsedt, _dtimg);
    cv::integral( _dtimg, _iimg, CV_64F);
}   // end ctor
开发者ID:richeytastic,项目名称:rfeatures,代码行数:9,代码来源:EDTFeature.cpp

示例10: Clusterer

OvershootClusterer::OvershootClusterer(const cv::Mat_<float> &img)
    : Clusterer(img), smallestOvershootVisit(img.size(), CLUSTERER_OVERSHOOTS),
      currRow(0), currCol(0), debugWindowName(NULL), debugX(-1), debugY(-1),
      temps(CLUSTERER_OVERSHOOTS)
{
    for (int i = 0; i < CLUSTERER_OVERSHOOTS; ++i)
    {
        //temps[i].marking.create(img.size());
        temps[i].emitsClusters = (i == 0 || !(i&(i-1)));
        // only emit clusters if 0,1,2,4,8,...
    }
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:12,代码来源:OvershootClusterer.cpp

示例11: openWindow

static int openWindow(const cv::Mat_<cv::Vec3b>& image)
{
	char *argv[1] = { 0 };
	int argc = 0;
	QApplication app(argc, argv);
	QWidget *window = new QWidget;
	QVBoxLayout *layout = new QVBoxLayout;

	// adapted from http://www.qtcentre.org/threads/11655-OpenCV-integration
	cv::Mat rgb = image;
	std::vector<cv::Mat> channels;
	cv::split(rgb, channels);  // split the image into r, g, b channels
	cv::Mat alpha = cv::Mat_<uchar>(image.size());
	alpha.setTo(cv::Scalar(255));
	channels.push_back(alpha);
	cv::Mat rgba = cv::Mat_<cv::Vec4b>(image.size());
	cv::merge(channels, rgba);  // add an alpha (so the image is r, g, b, a
	IplImage iplImage = (IplImage) rgba;  // get the raw bytes
	const unsigned char *imageData = (unsigned char *)(iplImage.imageData);
	QImage qimage(imageData, iplImage.width, iplImage.height, iplImage.widthStep,
		QImage::Format_RGB32); // and convert to a QImage

	QLabel *imageFrame = new QLabel;
	imageFrame->setPixmap(QPixmap::fromImage(qimage, 0));

	QPushButton *quit = new QPushButton(QString("Quit"));
    quit->setGeometry(62, 40, 75, 30);
    quit->setFont(QFont("Times", 18, QFont::Bold));
	window->connect(quit, SIGNAL(clicked()), &app, SLOT(quit()));

	layout->addWidget(new QLabel("top"));
	layout->addWidget(imageFrame);
	layout->addWidget(new QLabel("bottom"));
	layout->addWidget(quit);

	window->setLayout(layout);
	window->setWindowTitle(QString("Qt Image Display"));
	window->show();
	return app.exec();
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:40,代码来源:ImageViewer.cpp

示例12: detectColorEdge

void ColorEdge::detectColorEdge(const cv::Mat_<cv::Vec3b> &image, cv::Mat_<uchar> &edge)
{
    cv::Mat_<double> edge_map(image.size());
    const int filter_half = static_cast<int>(filter_size_ / 2);

    for(int y = filter_half; y < (edge_map.rows - filter_half); ++y)
    {
        for(int x = filter_half; x < (edge_map.cols - filter_half); ++x)
        {
            cv::Mat_<cv::Vec3b> roi(image, cv::Rect(x - filter_half, y - filter_half, filter_size_, filter_size_));
            edge_map(y, x) = calculateMVD(roi);
        }
    }
    
    edge_map.convertTo(edge, edge.type());
}
开发者ID:saigyo-k,项目名称:ForStudy,代码行数:16,代码来源:ColorEdge.cpp

示例13: normImage

cv::Mat_<cv::Vec3f> Utility::getChromacityImage(cv::Mat_<cv::Vec3f>& rgbImage) {
	///normalize r,g,b channels
	cv::Size imgSize=rgbImage.size();
	cv::Mat_<float> normImage(imgSize);
	normImage.setTo(cv::Scalar(0, 0, 0));
	cv::Mat_<cv::Vec3f> chromacityImage=rgbImage.clone();
	std::vector<cv::Mat_<float> > rgbPlanes;
	cv::split(rgbImage, rgbPlanes);
	cv::Mat_<float> singlePlane=normImage.clone();
	for (int i=0; i<3; i++) {
		cv::pow(rgbPlanes[i], 2.0, singlePlane);
		cv::add(normImage, singlePlane, normImage);
	}
	cv::sqrt(normImage, normImage);
	for (int i=0; i<3; i++) {
		cv::divide(rgbPlanes[i], normImage, rgbPlanes[i]);
	}
	cv::merge(&rgbPlanes[0], 3, chromacityImage);
	return chromacityImage;
}
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:20,代码来源:Utility.cpp

示例14: generate_gaussian_filter_ocv

void generate_gaussian_filter_ocv(cv::Mat_<T>& image, double sigma)
{
    const int w = image.size().width;
    const int h = image.size().height;
    const int wh = w / 2;
    const int hh = h / 2;

    const double s = 1.0 / (sigma*sigma);

    for (int y = -hh; y < hh; y++)
    {
        size_t yy = (y + h) % h;
        for (int x = -wh; x < wh; x++)
        {
            size_t xx = (x + w) % w;
            double fx = x;
            double fy = y;
            image(yy, xx) = std::exp(-(fx*fx + fy*fy) * s);
        }
    }
}
开发者ID:Sunwinds,项目名称:3D-Geometric-Features,代码行数:21,代码来源:galif.cpp

示例15: ComputeGradientTensor

cv::Mat ComputeGradientTensor(const cv::Mat_<double> &i1, const cv::Mat_<double> &i2, double hx, double hy){
  // for now give hx and hy as parameters, maybe later calculate them with ROI
  cv::Mat middle, kernel, t, x, y, xx, yy, xy, yx, xt, yt;

  middle = 0.5 * i1 + 0.5 * i2;
  t = i2 - i1;

  kernel = (cv::Mat_<double>(1,5) << 1, -8, 0, 8, -1);
  cv::filter2D(middle, x, CV_64F, kernel * 1.0/(12*hx), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);
  cv::filter2D(x, xx, CV_64F, kernel * 1.0/(12*hx), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);
  cv::filter2D(t, xt, CV_64F, kernel * 1.0/(12*hx), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);

  kernel = (cv::Mat_<double>(5,1) << 1, -8, 0, 8, -1);
  cv::filter2D(middle, y, CV_64F, kernel * 1.0/(12*hy), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);
  cv::filter2D(y, yy, CV_64F, kernel * 1.0/(12*hy), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);
  cv::filter2D(x, xy, CV_64F, kernel * 1.0/(12*hy), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);
  cv::filter2D(t, yt, CV_64F, kernel * 1.0/(12*hy), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);
  
  kernel = (cv::Mat_<double>(1,5) << 1, -8, 0, 8, -1);
  cv::filter2D(y, yx, CV_64F, kernel * 1.0/(12*hy), cv::Point(-1,-1), 0, cv::BORDER_REFLECT_101);

  xy = 0.5 * xy + 0.5 * yx;

  // channel 0=J11, 1=J22, 2=J33, 3=J12, 4=J13, 5=J23
  cv::Mat_<cv::Vec6d> b(i1.size());
  for (int i = 0; i < b.rows; i++){
    for (int j = 0; j < b.cols; j++){
      b(i,j)[0] = xx.at<double>(i,j) * xx.at<double>(i,j) + xy.at<double>(i,j) * xy.at<double>(i,j);
      b(i,j)[1] = xy.at<double>(i,j) * xy.at<double>(i,j) + yy.at<double>(i,j) * yy.at<double>(i,j);
      b(i,j)[2] = xt.at<double>(i,j) * xt.at<double>(i,j) + yt.at<double>(i,j) * yt.at<double>(i,j);
      b(i,j)[3] = xx.at<double>(i,j) * xy.at<double>(i,j) + xy.at<double>(i,j) * yy.at<double>(i,j);
      b(i,j)[4] = xx.at<double>(i,j) * xt.at<double>(i,j) + xy.at<double>(i,j) * yt.at<double>(i,j);
      b(i,j)[5] = xy.at<double>(i,j) * xt.at<double>(i,j) + yy.at<double>(i,j) * yt.at<double>(i,j);
    }
  }

  return b;
}
开发者ID:V-Italy,项目名称:optical_flow,代码行数:38,代码来源:tensor_computation.cpp


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