c - 尝试打印32位浮点图像的像素值

标签 c opencv

我正在尝试打印 32 位浮点图像的像素强度。这是我正在使用的代码。通过在 matlab 上的 imread 中查看,图像中有两种类型的值:NAN 和 float 。该程序加载图像,但在尝试运行时挂起。谁能告诉我出了什么问题。感谢您的帮助。

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

void printIplImage(const IplImage* src)
{
    int row = 0,col = 0;
    for(row = 0; row < src->height; row++)
    {
        for(col = 0; col < src->width; col++)
        {       
            printf("%f, ", ((float*)(src->imageData + src->widthStep*row))[col]);
        }
        printf("\n");
    }
}

int main(int argc, char** argv)
{
    IplImage *t3 = cvLoadImage("divimages1.tiff",CV_LOAD_IMAGE_UNCHANGED);

    printIplImage(t3);

    cvReleaseImage (&t3);
    return 0;
}

最佳答案

您确定图像数据加载为 32 位 float 吗?试试converting it explicitly as described here

关于c - 尝试打印32位浮点图像的像素值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10525625/

相关文章:

c - c中的pthread队列

c++ - 查找图像上的主色

c++ - 使用 OpenCV 将视频写入文件

c++ - Code::Blocks 中的 OpenCV:应用程序无法正确启动 (0xc00000be)

c - 利用缓冲区溢出读取操作

java - 在 Arduino IDE 中从串行获取的拆分数组字符

c - 将应用程序预处理器信息转发到静态库

c - 无符号字符的格式说明符

python - 如何在 OpenCV-Python 中打开带有 alpha channel 的图像?

c++ - OpenCv 中的 stitcher() 错误