2 asd13768331678 asd13768331678 于 2014.11.09 22:58 提问

关于在VS2008中的错误:error C2660: “cvCreateImage”: 函数不接受 1 个参数

代码如下,很急,谢各位
#include "stdafx.h"
#include "stdio.h"

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"

IplImage* DrawHistogram(CvHistogram* hist , float scaleX = 1, float scaleY = 1)
{

float histMax = 0;
cvGetMinMaxHistValue(hist , 0 ,&histMax ,0 ,0);
IplImage* imgHist = cvCreateImage(cvSize(256*scaleX , 64*scaleY));
cvZero(imgHist);

for(int i=0;i<255;i++)
{
    float histValue = cvQueryHistValue_1D( hist, i);
    float nextValue = cvQueryHistValue_1D( hist, i+1);


    CvPoint pt1 = cvPoint(i*scaleX , 64*scaleY);
    CvPoint pt2 = cvPoint((i+1)*scaleX , 64*scaleY);
    CvPoint pt3 = cvPoint((i+1)*scaleX , 64*scaleY - (nextValue/histMax)*64*scaleY);
    CvPoint pt4 = cvPoint(    i*scaleX , 64*scaleY - (nextValue/histMax)*64*scaleY);

    int numPts = 5;
    CvPoint pts[5];
    pts[0] = pt1;
    pts[1] = pt2;
    pts[2] = pt3;
    pts[3] = pt4;
    pts[4] = pt1;

    cvFillConvexPoly(imgHist , pts , numPts , cvScalar(255));

}

return imgHist;

}

int main(int argc, _TCHAR* argv[])
{
IplImage* src = cvLoadImage("E:\lena.jpg");
cvNamedWindow("src");
cvShowImage("src", src);

int dims = 1;
int size = 256;
float range[] = {0,255};
float* ranges[] = {range};

CvHistogram* hist;

hist = cvCreateHist(dims , &size , CV_HIST_ARRAY , ranges , 1);
cvClearHist(hist);

IplImage* imgRed = cvCreateImage(cvGetSize(src) , 8 ,1);
IplImage* imgGreen = cvCreateImage(cvGetSize(src) , 8 ,1);
IplImage* imgBlue = cvCreateImage(cvGetSize(src) , 8 ,1);

cvSplit(src , imgBlue , imgGreen , imgRed , NULL);


cvCalcHist(&imgBlue , hist , 0 , 0 );
IplImage* histBlue = DrawHistogram(hist);
cvClearHist(hist);

cvCalcHist(&imgGreen , hist , 0 , 0 );

IplImage* histGreen = DrawHistogram(hist);
cvClearHist(hist);

cvCalcHist(&imgRed , hist , 0 , 0 );

IplImage* histRed = DrawHistogram(hist);
cvClearHist(hist);

cvNamedWindow("B");
cvNamedWindow("G");
cvNamedWindow("R");

cvShowImage("B" , histBlue);
cvShowImage("G" , histGreen);
cvShowImage("R" , histRed);

cvWaitKey(0);
return 0;

}

1个回答

yinhening
yinhening   2014.11.10 09:20
IplImage* imgHist = cvCreateImage(cvSize(256*scaleX , 64*scaleY));

这里的问题
IplImage* cvCreateImage( CvSize size, int depth, int channels );
这个函数需要3个参数

asd13768331678
asd13768331678 大神,怎么改??
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!