Objective:
I am trying to use openCV function cvResize() to resample a 2D array.[I have a working code in opencv using cvResize, I know its usage] But the input 2D array which I want to resample is not any image read by openCV using cvLoadImage() instead –
1.I would want to read the 2D array from a text file I have. That file has floating point values, in it. I would open that file in this test code using opencv library, read the values in a 2D array of float.
2.Then use cvResize() to resize it. First I want to downsample it – width/2, height/2.
3.Then I want to upsample it by 4 – width*4, height*4. This is my final 2D array.
4.Store this final 2D array to a text file as floating point values.
5.Basically I want to use the Bilinear interpolation logic used by OpenCV, but on my own data. What path/which file can I see the code for cvResize()?
Any pointers appreciated.
The difficulty here seems to be that you are using a data type (2D array) to store the data read from the file, that is not compatible with what
cvResize()works with (it’sIplImage*remember?).If you are using the C interface of OpenCV (and by watching your other questions I know you are), after successfully reading the data from the file to your custom data type (2D array?) you need to create a
IplImage*that is big enough to store this information.IplImage* cv_data_img = cvCreateImage(cvSize(custom_data_height, custom_data_width), IPL_DEPTH_32F, 1);
and after that, you’ll have to iterate on
cv_data_imgcopying the original data.Once
cv_data_imgit’s filled with the data, you can create the othersIplImage*you’ll need to store the result ofcvResize().At the end, you can iterate on the resulting
IplImage*and copy it back to your original data type (2D array) or do whatever you want with it.