opencv IPL_DEPTH_32F的图像如何显示??
voidcalculateGradient(constIplImage*frame1,int&vfps){IplImage*frameGray=cvCreateImage...
void calculateGradient(const IplImage *frame1, int &vfps)
{
IplImage *frameGray = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_8U, 1);
IplImage *gradient = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_32F, 1);
IplImage *gradient1 = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_8U, 1);
cvCvtColor(frame1, frameGray, CV_RGB2GRAY);
//IplImage *gradientX, *gradientY;
IplImage *gradientX = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_16S, 1);
IplImage *gradientY = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_16S, 1);
cvSobel(frameGray,gradientY,0,1,3);
cvSobel(frameGray,gradientX,1,0,3);
for (int j = 0; j < gradientX->height; j++) {
float *ptrX = (float *) (gradientX->imageData + j * gradientX->widthStep);
float *ptrY = (float *) (gradientY->imageData + j * gradientY->widthStep);
float *ptr = (float *) (gradient->imageData + j * gradient->widthStep);
for (int i = 0; i < gradient->width; i++) {
ptr[i] = cvRound (sqrt(ptrX[i] * ptrX[i] + ptrY[i] * ptr[i]));
}
}
cvConvertScale(gradient, gradient1, 0.25, 0.0);
cvShowImage("gradient", gradient1);
cvWaitKey(vfps);
cvReleaseImage(&gradient);
cvReleaseImage(&gradient1);
cvReleaseImage(&frameGray);
cvReleaseImage(&gradientX);
cvReleaseImage(&gradientY);
} 展开
{
IplImage *frameGray = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_8U, 1);
IplImage *gradient = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_32F, 1);
IplImage *gradient1 = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_8U, 1);
cvCvtColor(frame1, frameGray, CV_RGB2GRAY);
//IplImage *gradientX, *gradientY;
IplImage *gradientX = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_16S, 1);
IplImage *gradientY = cvCreateImage(cvGetSize(frame1), IPL_DEPTH_16S, 1);
cvSobel(frameGray,gradientY,0,1,3);
cvSobel(frameGray,gradientX,1,0,3);
for (int j = 0; j < gradientX->height; j++) {
float *ptrX = (float *) (gradientX->imageData + j * gradientX->widthStep);
float *ptrY = (float *) (gradientY->imageData + j * gradientY->widthStep);
float *ptr = (float *) (gradient->imageData + j * gradient->widthStep);
for (int i = 0; i < gradient->width; i++) {
ptr[i] = cvRound (sqrt(ptrX[i] * ptrX[i] + ptrY[i] * ptr[i]));
}
}
cvConvertScale(gradient, gradient1, 0.25, 0.0);
cvShowImage("gradient", gradient1);
cvWaitKey(vfps);
cvReleaseImage(&gradient);
cvReleaseImage(&gradient1);
cvReleaseImage(&frameGray);
cvReleaseImage(&gradientX);
cvReleaseImage(&gradientY);
} 展开
展开全部
32位的显示和灰度图显示貌似在opencv里面是没有区别的,你把最后一行cvshowimage()里面的gradient1直接改成gradient试试,就是你不用再转化成灰度图像显示,直接显示出来。
更多追问追答
追问
一样的啊。。。。
追答
我不懂,你的问题究竟出在哪里,你貌似就是进行了一个sobel边缘提取吧,你要显示出什么东西来?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询