IplImage convertion to Mat
what is the IplImage.imagedata[0] equivalent to in Mat format ?
what is the IplImage.imagedata[0] equivalent to in Mat format ?
Hi, from IplImage and Mat documentations :
char* IplImage::**imageData //Pointer to aligned image data.
class CV_EXPORTS Mat
{
public:
...
//! pointer to the data
**uchar* data;**
....
};
If you what pixel access to Mat u can use pointer :
Mat image;
uchar* ptr = image.data();
( use uchar type of pointer for type of Mat like CV_8UC1 )
IplImage.imagedata[0]
equivalent to ptr[0]
Note that if its a color Mat with 3 channels pixels are saved in data sequentially ( BGRBGR...).
or at method : Mat::at(int i, int j)
where i – Index along the dimension 0, j – Index along the dimension 1
Here it's the simplest way to convert iplImage to MAT
IplImage ipl_img;
Mat mat_img(ipl_img );
And Here you can Convert MAT to iplimage
Mat mat_img;
IplImage ipl_img = mat_img;
As I know, The imageData is a pointer (char *) to the image raw data in the IplImage
structure . You can access to the same location of memory by using these lines of codes:
unsigned char *imagePointer = (unsigned char*) (image.data);
or
char *imagePointer = (char*) (image.data);
where the image
is cv::Mat
Consequently the imagePointer[0] is equivalent to IplImage.imagedata[0]
Asked: 2015-04-25 17:57:44 -0600
Seen: 3,415 times
Last updated: Apr 28 '15
C++ map with <cv::Mat, IplImage*> key-value format
Why is my call to putText creating a wavy image of lines?
How to create a binary image mat?
What is the most effective way to access cv::Mat elements in a loop?
How to reduce false positives for face detection
How to convert Floating point image to 32-bit single-channel?
OpenCV DescriptorMatcher matches
Record/Store constant refreshing coordinates points into notepad