Ask Your Question
0

IplImage convertion to Mat

asked 2015-04-25 17:57:44 -0600

215 gravatar image

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

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
1

answered 2015-04-26 07:22:00 -0600

fedor gravatar image

updated 2015-04-26 07:24:51 -0600

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

edit flag offensive delete link more

Comments

1

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

215 gravatar image215 ( 2015-04-26 08:28:05 -0600 )edit
1

Is this the question ? :D Try to use google

fedor gravatar imagefedor ( 2015-04-26 09:46:00 -0600 )edit
0

answered 2015-04-28 05:49:39 -0600

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;
edit flag offensive delete link more
0

answered 2015-04-26 06:50:25 -0600

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]

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-25 17:57:44 -0600

Seen: 2,943 times

Last updated: Apr 28 '15