使用cvMat编写cvGetImage时出现问题

使用cvMat编写cvGetImage时出现问题

本文介绍了使用cvMat编写cvGetImage时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从cvMat写入图像时遇到问题.

I am facing a problem while writing image from cvMat.

这就是我所做的.

IplImage* low_threshold_mask = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
CvMat* labelMat = cvCreateMat(low_threshold_mask->height,low_threshold_mask->width,CV_32F);

/*我在函数内填充了labelMat的元素.它是这样完成的:cvmSet(labelMat,r,c,label); //标签的类型为 long */

/* I populate elements of labelMat inside a function. Its done like this: cvmSet(labelMat,r,c,label); // where label is of type long */

要检查这些值,我将每个像素值转储到文本文件中,然后转储图像.

To check the values I dump each pixel value in a text file and also dump the image.

IplImage* labelImg;
IplImage imageHeader;
labelImg = cvGetImage(labelMat, &imageHeader);

现在,当我对转储的文本文件中的像素强度和相应值进行交叉检查时,我发现不匹配.我觉得我在文本文件中有正确的值,但在图像中有错误的值.

Now when I cross-check pixel intensity with corresponding value in dumped text file, I find mis-match. I feel I have got correct values in text file but wrong ones in image.

任何人都可以帮助找出错误吗?

Can anyone help in figuring out the mistake?

---------------------新添加内容-------------------

---------------------New addition-------------------

我仍然面临问题.我已经上传了程序.我将解释我到底在哪里遇到错误.

I am still facing the problem. I have uploaded my programs. I will explain where exactly I am facing the error.

:与openCV一起使用的是Boost库的不相交集.

Libraries used: Along with openCV, I am using disjoint_sets of boost library.

基本上,我正在做连接的组件标签.出于调试目的,对于第20帧,我将每个像素的标签信息都转储到a)文本文件中,并且b)强度级别与像素的最终标签相同的图像.因此,我期望文本和图像中的值相同.但这没有发生.我不知道为什么.文本文件显示正确的值,但不显示图像.我正在检查Matlab中图像的像素值(我已经在matlab中处理过从1开始而不是0的索引).

Basically I am doing connected component labeling.For debugging purpose, for 20th frame, I have dumped the label info of each pixel both in a)text file as well b) an image with intensity levels same as the final label of the pixels. So i am expecting the values same in both text and image. But that's not happening. And I am unable to figure out why. The text files shows the correct values but not the image. I am checking pixel values of image in Matlab(i had taken care of indices in matlab starts with 1 not 0).

我的文本文件a)(frame20final.txt)被填充到GrimsonGMM.cpp/ConCompLabeling()中.b)(frame20image.txt)被填充到main.cpp中我转储的图像(frame-ccs.jpg)已填充到main.cpp中.

My text filesa) (frame20final.txt) gets populated in GrimsonGMM.cpp/ConCompLabeling().b) (frame20image.txt) gets populated in main.cppMy dumped image(frame-ccs.jpg) gets populated in main.cpp.

两个文本文件都获得相同的值. 因此,从CvMat编写图像时一定会有一些错误.

Both the text files get same values. So there must be some mistake in writing the image from CvMat.

测试视频: person15_walking_d1_uncomp.avi 您也可以尝试其他任何视频.

Test Video: person15_walking_d1_uncomp.aviYou can try with any other video also.

预先感谢,考施克

推荐答案

我理解为什么会收到错误消息.我正在转储正在压缩的 .jpg 图片.当我使用.png

I understood why I was getting the error. I was dumping in .jpg image which was doing compression. This was resolved when I used .png

这篇关于使用cvMat编写cvGetImage时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 22:17