Ask Your Question
0

IplImage convertion to Mat

asked Apr 25 '15

215 gravatar image

what is the IplImage.imagedata[0] equivalent to in Mat format ?

Preview: (hide)

3 answers

Sort by » oldest newest most voted
1

answered Apr 26 '15

fedor gravatar image

updated Apr 26 '15

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

Preview: (hide)

Comments

1

The data type Mat are capable of converting to IplImage from which i can use the image data..

215 gravatar image215 (Apr 26 '15)edit
1

Is this the question ? :D Try to use google

fedor gravatar imagefedor (Apr 26 '15)edit
0

answered Apr 28 '15

essamzaky gravatar image

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;
Preview: (hide)
0

answered Apr 26 '15

Amin_Abouee gravatar image

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]

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Apr 25 '15

Seen: 3,612 times

Last updated: Apr 28 '15