通过函数调用使用pyrdown

时间:2015-10-03 17:23:28

标签: c++ opencv computer-vision image-scaling

我试图使用pyrDown()来缩小所需的图像。为此我使用了函数调用void downscale(Mat *p,int *scale)。我将ref发送到函数的函数。所以,在函数之后完成对图像的下采样我的原始图像将被发送,因为我发送了指针。图像在函数调用中被缩放。但令我惊讶的是,主程序中的图像没有变化。我不明白我哪里出错了。有人可以指出我的错误吗? 这是我的代码

#include <opencv2/core/core.hpp>
#include<opencv2/opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<stdio.h>
#include<conio.h>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/objdetect/objdetect.hpp>
#include<opencv2/features2d/features2d.hpp>
#include<opencv2/nonfree/nonfree.hpp>

using namespace std;
using namespace cv;

void downscale(Mat *p,int scale)
{
	int s=scale;

	Mat ref=*p;
	
	imshow("received",ref);
	vector<int> param;
	param.push_back(CV_IMWRITE_PNG_COMPRESSION) ;
	param.push_back(9);

	while(s){
	pyrDown(ref,ref,Size(),4);
	s--;
	}
	imshow("sending",ref);
}



int main()
{
	Mat ref,in,ref_out,in_out;
	int s=2;
	ref=imread("C:\\Users\\vamsidhar muthireddy\\Pictures\\Camera Roll\\WIN_20151003_18_47_55_Pro.jpg");

	cvtColor(ref,ref,CV_BGR2GRAY);

	

	imshow("original ref",ref);
	downscale(&ref,s);

	imshow("scaled ref",ref);

    waitKey();
	return 0;
}

1 个答案:

答案 0 :(得分:0)

将缩小范围更改为:

pos/1.txt

并将其命名为:

void downscale(Mat &ref,int scale)
{
int s=scale;

imshow("received",ref);
vector<int> param;
param.push_back(CV_IMWRITE_PNG_COMPRESSION) ;
param.push_back(9);

while(s){
pyrDown(ref,ref,Size(),4);
s--;
}
imshow("sending",ref);