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


C++ Mat::mul方法代码示例

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


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

示例1: image_jacobian_affine_ECC

static void image_jacobian_affine_ECC(const Mat& src1, const Mat& src2,
                                      const Mat& src3, const Mat& src4,
                                      Mat& dst)
{

    CV_Assert(src1.size() == src2.size());
    CV_Assert(src1.size() == src3.size());
    CV_Assert(src1.size() == src4.size());

    CV_Assert(src1.rows == dst.rows);
    CV_Assert(dst.cols == (6*src1.cols));

    CV_Assert(dst.type() == CV_32FC1);


    const int w = src1.cols;

    //compute Jacobian blocks (6 blocks)

    dst.colRange(0,w) = src1.mul(src3);//1
    dst.colRange(w,2*w) = src2.mul(src3);//2
    dst.colRange(2*w,3*w) = src1.mul(src4);//3
    dst.colRange(3*w,4*w) = src2.mul(src4);//4
    src1.copyTo(dst.colRange(4*w,5*w));//5
    src2.copyTo(dst.colRange(5*w,6*w));//6
}
开发者ID:Linyes,项目名称:opencv,代码行数:26,代码来源:ecc.cpp

示例2: image_jacobian_euclidean_ECC

static void image_jacobian_euclidean_ECC(const Mat& src1, const Mat& src2,
                                         const Mat& src3, const Mat& src4,
                                         const Mat& src5, Mat& dst)
{

    CV_Assert( src1.size()==src2.size());
    CV_Assert( src1.size()==src3.size());
    CV_Assert( src1.size()==src4.size());

    CV_Assert( src1.rows == dst.rows);
    CV_Assert(dst.cols == (src1.cols*3));
    CV_Assert(dst.type() == CV_32FC1);

    CV_Assert(src5.isContinuous());

    const float* hptr = src5.ptr<float>(0);

    const float h0 = hptr[0];//cos(theta)
    const float h1 = hptr[3];//sin(theta)

    const int w = src1.cols;

    //create -sin(theta)*X -cos(theta)*Y for all points as a block -> hatX
    Mat hatX = -(src3*h1) - (src4*h0);

    //create cos(theta)*X -sin(theta)*Y for all points as a block -> hatY
    Mat hatY = (src3*h0) - (src4*h1);


    //compute Jacobian blocks (3 blocks)
    dst.colRange(0, w) = (src1.mul(hatX))+(src2.mul(hatY));//1

    src1.copyTo(dst.colRange(w, 2*w));//2
    src2.copyTo(dst.colRange(2*w, 3*w));//3
}
开发者ID:Linyes,项目名称:opencv,代码行数:35,代码来源:ecc.cpp

示例3: get_ft

Mat get_ft(Mat &src1, Mat &src2){
    Mat ft;
    Mat kernel = Mat::ones(2, 2, CV_64FC1);
    kernel = kernel.mul(-1);
    
    Mat dst1, dst2;
    filter2D(src1, dst1, -1, kernel);
    kernel = kernel.mul(-1);
    filter2D(src2, dst2, -1, kernel);
    
    ft = dst1 + dst2;
    return ft;
}
开发者ID:mileslindheimer,项目名称:optical-flow,代码行数:13,代码来源:parallelVideo.cpp

示例4: blendLapPyrs

	void blendLapPyrs() {
		//获得每层金字塔中直接用左右两图Laplacian变换拼成的图像resultLapPyr
		resultHighestLevel = leftHighestLevel.mul(maskGaussianPyramid.back()) +
			rightHighestLevel.mul(Scalar(1.0,1.0,1.0) - maskGaussianPyramid.back());
		for (int l=0; l<levels; l++) {
			Mat A = leftLapPyr[l].mul(maskGaussianPyramid[l]);
			Mat antiMask = Scalar(1.0,1.0,1.0) - maskGaussianPyramid[l];
			Mat B = rightLapPyr[l].mul(antiMask);
			Mat_<Vec3f> blendedLevel = A + B;

			resultLapPyr.push_back(blendedLevel);
		}
	}
开发者ID:huaijin-chen,项目名称:SIFT.huaijin,代码行数:13,代码来源:laplasi.cpp

示例5: fpropOne

	// ----------------------------------------------------------------------------
	//
	//								private function impl
	//
	// ----------------------------------------------------------------------------
	void FCDropoutLayer::fpropOne(Mat &ouFeatMaps, Mat &mask, 
								  const Mat &inFeatMaps, 
								  const float dropoutRate,
								  const bool isStaticMask)
	{
		float scale = 1 / (1 - dropoutRate);
		if (!isStaticMask) {
			cv::randu(mask, 0, 1);
			cv::threshold(mask, mask, dropoutRate, scale, CV_THRESH_BINARY);
			ouFeatMaps = inFeatMaps.mul(mask);
		}
		else
			ouFeatMaps = inFeatMaps.mul(mask);
	}
开发者ID:ZjjConan,项目名称:PolyU-GuidedStudy-CNN,代码行数:19,代码来源:dropoutLayer.cpp

示例6: cvt2NonLinear

Mat cvt2NonLinear(Mat srcImg)  {
	int choice;
	double c;
	cout << "\nCHUYEN MAU THEO MO HINH PHI TUYEN TINH" << endl;
	cout << "Chon 1 trong 2 cach sau: " << endl;
	cout << "   1.Chuyen theo ham logarithm." << endl;
	cout << "   2.Chuyen theo ham mu." << endl;
	cout << "Lua chon: ";
	cin >> choice;

	switch (choice)  {
	case 1:  {
		cout << "   - Nhap gia tri c: ";
		cin >> c;
		myfunc_nonLinearChange_Log(srcImg, c);
		// Tạo ảnh kết quả (res) có kích thước và kiểu giống ảnh gốc (srcImg) nhưng các giá trị = 0
		Mat res = Mat::zeros(srcImg.size(), srcImg.type());
		// + 1 để tránh log(0)
		srcImg = srcImg + 1;
		// Chuyển định dạng pixel của ảnh gốc (srcImg) thành CV_32F - dạng float để tính logarithm
		srcImg.convertTo(srcImg, CV_32F);
		// Ảnh kết quả = log(Ảnh gốc)
		log(srcImg, res);
		// Chuyển về [0..255]
		normalize(res, res, 0, 255, NORM_MINMAX);
		convertScaleAbs(res, res);
		// Ảnh kết quả = Ảnh kết quả * c
		res.mul(res, c);
		return res;
	}
	case 2:  {
		cout << "   - Nhap gia tri c: ";
		cin >> c;
		myfunc_nonLinearChange_Exp(srcImg, c);
		// Tạo ảnh kết quả (res) có kích thước và kiểu giống ảnh gốc (srcImg) nhưng các giá trị = 0
		Mat res = Mat::zeros(srcImg.size(), srcImg.type());
		// Chuyển định dạng pixel của ảnh gốc (srcImg) thành CV_32F - dạng float để tính logarithm
		srcImg.convertTo(srcImg, CV_32F);
		// Ảnh kết quả = e ^ (Ảnh gốc)
		exp(srcImg, res);
		res.mul(c);
		return res;
	}

			default:
				return Mat();
	}
}
开发者ID:hungnguyen0606,项目名称:ImageProcessing,代码行数:48,代码来源:Main.cpp

示例7: naive_convolution

/* finds the convolution of a matrix and kernel
 * the input should be an 1-channel floating point image 
 * written as an illustration only */
int naive_convolution(const Mat& input, Mat& output, const Mat& kernel)
{
    int krows = kernel.rows;
    int kcols = kernel.cols;

    /* region of interest */
    Mat roi = input(cv::Rect(0, 0, krows, kcols));

    for (int r = 0; r < output.rows; r++) {
        for (int c = 0; c < output.cols; c++) {
            float& pixel = output.at<float>(r, c);

            if ((r < krows / 2) || (r > output.rows - krows / 2 - 1)
             || (c < kcols / 2) || (c > output.cols - kcols / 2 - 1)) {
                /* set out of bounds pixels to black */
                pixel = 0;
            } else {
                /* move the ROI */
                roi = input(cv::Rect(c - kcols / 2, r - krows / 2,
                                     kcols, krows));

                /* perform element-wise multiplication and take the sum
                 * to get the value of the current pixel */
                pixel = sum(kernel.mul(roi))[0];
            }
        }
    }
    return 0;
}
开发者ID:hucal,项目名称:cv-composer,代码行数:32,代码来源:convolution.cpp

示例8: goFiltre

void FiltreElip::goFiltre(Mat& img, Mat& gray, Mat& effet){

	Mat work_on;
	if(_image_we_work_on==0){
		equalizeHist( gray, work_on );
	}
	else{
		equalizeHist( effet, work_on );
	}
	int rows=work_on.rows;
	int cols=work_on.cols;
//	std::cout << rows << " rows" << std::endl;
//	std::cout << cols << " cols" << std::endl;
	int trying=0;
	
	for(int i=0;i<rows-_filtre1.rows;i=i+5){
		for(int j=0;j<cols-_filtre1.cols;j=j+5){
			Mat tmp = work_on(Range(i,i+_filtre1.rows), Range(j,j+_filtre1.cols));

			tmp.mul(_filtre1);			
			trying=sum(tmp).val[0];
			
			
			if(_sum1>trying || _sum1==-1){
			//std::cout<<"sum : "<<_sum1 <<" "<< trying << std::endl;
				_sum1=trying;
				_rec1=Rect(j,i,_filtre1.rows,_filtre1.cols);
					
			}
		}
	}
}
开发者ID:4sskick,项目名称:Eye-tracking_usingC--,代码行数:32,代码来源:FiltreElip.cpp

示例9: makeTile

void TileHolder::makeTile(const GridPt &tilePt, ImgFetcher &fetch, Mat &out, Mat &bg) {
	Point2f tileTl(tl.x + tilePt[0] * tileSz.width, tl.y + tilePt[1] * tileSz.height);

	const set<ImData> &bin = getBin(tilePt);
	out = Mat::zeros(tileSz, CV_32FC1);//gather the tile data in out
	
	Mat weightIm = Mat::zeros(tileSz, CV_32FC1) + FLT_MIN;//+ 1e-90;	// avoid divide by zero, maybe static this?

	Mat curIm;
	for (const ImData &dat : bin) {
		fetch.getMat(dat.file, curIm);
		if (curIm.type() == CV_8U) {
			curIm.convertTo(curIm, CV_32F, 1. / 255);
		} else if (curIm.type() != CV_32F) {
			fprintf(stderr, "err: bad image type\n");
			exit(1);
		}

		if (bg.data)
		{
			assert(bg.size() == curIm.size());
			curIm -= bg;
		}

		std::cout << dat.file << std::endl;
		//saveFloatIm("testsomewhere.tif", weightMat);
		blit(curIm.mul(weightMat), out, dat.pos - tileTl);
		blit(weightMat, weightIm, dat.pos - tileTl);
	}
	out /= weightIm;
}
开发者ID:ICpachong,项目名称:superstitchous2.0,代码行数:31,代码来源:stitch.cpp

示例10: getAverage

  /**
   * Get the average image at the given altitude.
   * If the altitude is not located exactly at one of the altitude bins,
   * the average image is interpolated between any overlapping bins.
   * @param _dst the output image (zeros at desired resolution)
   * @param alt the altitude the image was taken at
   * @param pitch the pitch of the vehicle
   * @param roll the roll of the vehicle
   */
  void getAverage(cv::OutputArray _dst, double alt, double pitch, double roll) {
    Mat dst = _dst.getMat();
    int width = dst.size().width;
    int height = dst.size().height;
    Mat D = Mat::zeros(height, width, CV_32F);
    double width_m = width * cameras.pixel_sep;
    double height_m = height * cameras.pixel_sep;
    interp::distance_map(D, alt, pitch, roll, width_m, height_m, cameras.focal_length);
    // now discretize into slices
    int i = 0;
    Mat W = Mat::zeros(D.size(), CV_32F);
    while(cv::countNonZero(W) == 0) {
      interp::dist_weight(D, W, alt_step, i++);
    }
    while(cv::countNonZero(W) > 0) {
      Slice<int>* slice = getSlice(i);
      Mat sAverage;
      // get the slice average
      boost::mutex* mutex = slice->get_mutex();
      { // protect slice with mutex to prevent interleaved read/write operations
	boost::lock_guard<boost::mutex> lock(*mutex);
	sAverage = slice->getLightfield()->getAverage();
      }
      dst += sAverage.mul(W); // multiply by slice weight
      interp::dist_weight(D, W, alt_step, i++);
    }
  }
开发者ID:joefutrelle,项目名称:bic,代码行数:36,代码来源:VehicleLighfield.hpp

示例11: dSigmoid

Mat dSigmoid(Mat& mat)
{
	Mat res = 1.0 - mat;
    res = res.mul(mat);
	return res;

}
开发者ID:1056739724,项目名称:dl-simplecnn,代码行数:7,代码来源:supportOperator.cpp

示例12: specgram_to_cepsgram

void specgram::specgram_to_cepsgram(const Mat& specgram,
                                    const Mat& filter_bank,
                                    Mat& cepsgram)
{
    cepsgram = (specgram.mul(specgram) / specgram.cols) * filter_bank;
    cv::log(cepsgram, cepsgram);
    return;
}
开发者ID:leliaonvidia,项目名称:aeon,代码行数:8,代码来源:specgram.cpp

示例13: PhaseShiftCoefficientRealPart

Mat PhaseShiftCoefficientRealPart(Mat laplevel, Mat rieszXLevel, Mat rieszYLevel, Mat phaseMagnifiedCos, Mat phaseMagnifiedSin)
{
    Mat r;
    Mat pm,expPhaseReal,expPhaseImag;
    Mat expphix,expphiy,tmp;

    sqrt(phaseMagnifiedCos.mul(phaseMagnifiedCos)+phaseMagnifiedSin.mul(phaseMagnifiedSin),pm);
    expPhaseReal = Cos(pm);
    expPhaseImag = Sin(pm);
    divide(expPhaseImag,pm,tmp);
    expphix = phaseMagnifiedCos.mul(tmp);
    expphiy = phaseMagnifiedSin.mul(tmp);

    r = expPhaseReal.mul(laplevel)-expphix.mul(rieszXLevel)-expphiy.mul(rieszYLevel);

    return r;
}
开发者ID:LaurentBerger,项目名称:AmplificationMouvement,代码行数:17,代码来源:main.cpp

示例14: wav_to_specgram

// These can all be static
void specgram::wav_to_specgram(const Mat& wav_col_mat,
                               const int frame_length_tn,
                               const int frame_stride_tn,
                               const int max_time_steps,
                               const Mat& window,
                               Mat& specgram)
{
    // const Mat& wav_mat = wav.get_data();
    // Read as a row vector
    Mat wav_mat = wav_col_mat.reshape(1, 1);

    // TODO: support more sample formats
    if (wav_mat.elemSize1() != 2) {
        throw std::runtime_error(
                "Unsupported number of bytes per sample: " + std::to_string(wav_mat.elemSize1()));
    }

    // Go from time domain to strided signal
    Mat wav_frames;
    {
        int num_frames = ((wav_mat.cols - frame_length_tn) / frame_stride_tn) + 1;
        num_frames = std::min(num_frames, max_time_steps);
        // ensure that there is enough data for at least one frame
        assert(num_frames >= 0);

        wav_frames.create(num_frames, frame_length_tn, wav_mat.type());
        for (int frame = 0; frame < num_frames; frame++) {
            int start = frame * frame_stride_tn;
            int end   = start + frame_length_tn;
            wav_mat.colRange(start, end).copyTo(wav_frames.row(frame));
        }
    }

    // Prepare for DFT by converting to float
    Mat input;
    wav_frames.convertTo(input, CV_32FC1);

    // Apply window if it has been created
    if (window.cols == frame_length_tn) {
        input = input.mul(cv::repeat(window, input.rows, 1));
    }

    Mat planes[] = {input, Mat::zeros(input.size(), CV_32FC1)};
    Mat compx;
    cv::merge(planes, 2, compx);
    cv::dft(compx, compx, cv::DFT_ROWS);
    compx = compx(Range::all(), Range(0, frame_length_tn / 2  + 1));

    cv::split(compx, planes);
    cv::magnitude(planes[0], planes[1], planes[0]);

    // NOTE: at this point we are returning the specgram representation in
    // (time_steps, freq_steps) shape order.

    specgram = planes[0];

    return;
}
开发者ID:leliaonvidia,项目名称:aeon,代码行数:59,代码来源:specgram.cpp

示例15: rateBubble

//Rate a location on how likely it is to be a bubble
double rateBubble(Mat& det_img_gray, Point bubble_location, PCA& my_PCA){
	Mat query_pixels, pca_components;
	getRectSubPix(det_img_gray, Point(14,18), bubble_location, query_pixels);
	query_pixels.reshape(0,1).convertTo(query_pixels, CV_32F);
	pca_components = my_PCA.project(query_pixels);
	//The rating is the SSD of query pixels and their back projection
	Mat out = my_PCA.backProject(pca_components)- query_pixels;
	return sum(out.mul(out)).val[0];
}
开发者ID:elwinschonweiss,项目名称:mScan,代码行数:10,代码来源:checkBubbles.cpp


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