Why Iplimage using char* pointing to raw image data instead of unsigned char* pointer just like Mat did?
Here's the data structure of Iplimage:
typedef struct _IplImage {
int nSize;
int ID;
int nChannels;
int alphaChannel;
int depth;
char colorModel[4];
char channelSeq[4];
int dataOrder;
int origin;
int align;
int width;
int height;
struct _IplROI* roi;
struct _IplImage* maskROI;
void* imageId;
struct _IplTileInfo* tileInfo;
int imageSize;
char* imageData;
int widthStep;
int BorderMode[4];
int BorderConst[4];
char* imageDataOrigin;
} IplImage;
As I said, the pointer to imageData is a char*.
class CV_EXPORTS Mat
{
public:
// ... a lot of methods ...
...
/*! includes several bit-fields:
- the magic signature
- continuity flag
- depth
- number of channels
*/
int flags;
//! the array dimensionality, >= 2
int dims;
//! the number of rows and columns or (-1, -1) when the array has more than 2 dimensions
int rows, cols;
//! pointer to the data
uchar* data;
//! pointer to the reference counter;
// when array points to user-allocated data, the pointer is NULL
int* refcount;
// other members
...
};
The pointer to data is uchar* which is unsigned char*.
Here rises a problem that we all know the elements of a color(gray, RGB which are commonly used while loading image) ranges from 0~255, which can be adequately expressed by 8 bits(unsigned char).
Why don't use uchar* in the Iplimage data structure, same as Mat did?
Why are you taking about Mat structures in past, and about IplImage in present? IplImage is old deprecated...
because I knew Mat before I got to know Iplimage. I know that Iplimage is deprecated, what I want to know is that why is Iplimage defined like that, since the rang of the color hasn't changed over time.
Because it was ineffectively programmed, then someone in the past decided to do it more efficiently in the Mat structure. But in order to allow backwards compatibility, we cannot change the char pointer to a uchar pointer. Simple as that.