开发者社区> 问答> 正文

关于在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;
}

展开
收起
a123456678 2016-03-05 10:33:18 3655 0
1 条回答
写回答
取消 提交回答
  • IplImage imgHist = cvCreateImage(cvSize(256scaleX , 64*scaleY));
    这里的问题
    IplImage* cvCreateImage( CvSize size, int depth, int channels );
    这个函数需要3个参数

    2019-07-17 18:53:00
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载