开发者

Opencv: from floating point to

开发者 https://www.devze.com 2023-03-16 05:38 出处:网络
I have following type of data in a text file(number of row =4000, number of column =141).First 5*5 element of that data here to give you an idea:

I have following type of data in a text file(number of row =4000, number of column =141).First 5*5 element of that data here to give you an idea:

1.05E-01    1.05E-01    1.04E-01    1.04E-01    1.04E-01
1.03E-01    1.04E-01    1.04E-01    1.03E-01    1.04E-01
1.04E-01    1.04E-01    1.04E-0开发者_运维技巧1    1.04E-01    1.03E-01
1.04E-01    1.04E-01    1.05E-01    1.04E-01    1.04E-01
1.03E-01    1.03E-01    1.04E-01    1.05E-01    1.03E-01

I want to make a grayscale image with this data.

  1. How can I scale data before I feed into openCV?

  2. How can I generate output of 512 X 512 dimension?

  3. What is the wrong with the following code?

    IplImage *img = (cvSize(4000, 141), IPL_DEPTH_32F, 1);
    
    freopen ("D:\\input.txt", "r", stdin);
    int i;
    float data;
    for (i = 0; i < img->width * img->height ; i++) 
    {
        scanf("%e",&data);
                data*=2500;//for scaling data roughly
        ((float*)img->imageData)[i] =data; 
    }
    
    cvNamedWindow ("image", 1);
    
    cvShowImage ("image", img);
    
    cvWaitKey (0);
    
    cvReleaseImage (&img);
    
    cvDestroyWindow("image");
    


This line alone generates a compiling error:

IplImage *img = (cvSize(4000, 141), IPL_DEPTH_32F, 1); 

I'm pretty sure that you wanted to put a cvCreateImage() there, but if you want serious help than you better post good code (and good code is usually free of errors, or very close to that).

  1. Why not feed this data into OpenCV and then use OpenCV to scale your image?

  2. You can use cvResize() to change the dimension of your image.

  3. I take it that this is a grayscale image, because you are creating it with only one channel. Your values should be in the range 0.0 to 1.0 for IPL_DEPTH_32F images, so make sure of that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号