YARP
Yet Another Robot Platform
IplImage.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 1995, 2000 Intel Corporation
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 // originates from cvtypes.h in intel OpenCV project,
11 // some local modifications.
12 
13 // check if CV is present
14 #ifndef _CV_H_
15 // check if IPL is present
16 #ifndef HAVE_IPL
17 // or asserted to be present
18 #ifndef HAVE_OPENCV
19 
20 #ifndef YARP_CVTYPES_H_
21 #define YARP_CVTYPES_H_
22 
23 // To simplify interaction with opencv header files, say that we
24 // have ipl headers
25 // We may fail anyway, but we will certainly fail otherwise.
26 #ifndef HAVE_IPL
27 #define HAVE_IPL
28 #endif
29 
30 
31 #include <cassert>
32 #include <cstdlib>
33 
34 #if defined _MSC_VER || defined __BORLANDC__
35 typedef __int64 int64;
36 typedef unsigned __int64 uint64;
37 #else
38 typedef long long int64;
39 typedef unsigned long long uint64;
40 #endif
41 
42 #ifndef __IPL_H__
43 typedef unsigned char uchar;
44 #endif
45 
46 
47 
48 
49 /****************************************************************************************\
50  * Image type (IplImage) *
51 \****************************************************************************************/
52 
53 /*
54  * The following definitions (until #endif)
55  * is an extract from IPL headers.
56  * Copyright (c) 1995 Intel Corporation.
57  */
58 
59 #define IPL_DEPTH_SIGN 0x80000000
60 
61 #define IPL_DEPTH_1U 1
62 #define IPL_DEPTH_8U 8
63 #define IPL_DEPTH_16U 16
64 #define IPL_DEPTH_32F 32
65 
66 #define IPL_DEPTH_8S (int)(IPL_DEPTH_SIGN| 8)
67 #define IPL_DEPTH_16S (int)(IPL_DEPTH_SIGN|16)
68 #define IPL_DEPTH_32S (int)(IPL_DEPTH_SIGN|32)
69 
70 #define IPL_DATA_ORDER_PIXEL 0
71 #define IPL_DATA_ORDER_PLANE 1
72 
73 #define IPL_ORIGIN_TL 0
74 #define IPL_ORIGIN_BL 1
75 
76 #define IPL_ALIGN_4BYTES 4
77 #define IPL_ALIGN_8BYTES 8
78 #define IPL_ALIGN_16BYTES 16
79 #define IPL_ALIGN_32BYTES 32
80 
81 #define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES
82 #define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES
83 
84 typedef struct _IplImage {
85  int nSize;
86  int ID;
87  int nChannels;
89  int depth;
91  char colorModel[4];
92  char channelSeq[4];
93  int dataOrder;
95  int origin;
97  int align;
99  int width;
100  int height;
101  struct _IplROI *roi;
102  struct _IplImage *maskROI;
103  void *imageId;
104  struct _IplTileInfo *tileInfo;
105  int imageSize;
108  char *imageData;
109  int widthStep;
110  int BorderMode[4];
111  int BorderConst[4];
115 }
117 
118 typedef struct _IplTileInfo IplTileInfo;
119 
120 typedef struct _IplROI {
121  int coi;
122  int xOffset;
123  int yOffset;
124  int width;
125  int height;
126 }
128 
129 typedef struct _IplConvKernel
130 {
131  int nCols;
132  int nRows;
133  int anchorX;
134  int anchorY;
135  int *values;
136  int nShiftR;
137 }
139 
140 typedef struct _IplConvKernelFP
141 {
142  int nCols;
143  int nRows;
144  int anchorX;
145  int anchorY;
146  float *values;
147 }
149 
150 #define IPL_IMAGE_HEADER 1
151 #define IPL_IMAGE_DATA 2
152 #define IPL_IMAGE_ROI 4
153 
154 #ifndef IPL_IMAGE_MAGIC_VAL
155 #define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage))
156 #endif
157 
158 /* for file storages make the value independent from arch */
159 #ifndef IPL_IMAGE_FILE_MAGIC_VAL
160 #define IPL_IMAGE_FILE_MAGIC_VAL 112
161 #endif
162 
163 #ifndef IPL_DEPTH_64F
164 #define IPL_DEPTH_64F 64 /* for storing double-precision
165  floating point data in IplImage's */
166 #endif
167 
168 
169 // to fool a few Windows declarations.
170 //typedef int HDC;
171 //typedef char _TCHAR;
172 
179 int _iplCalcPadding (int lineSize, int align);
180 
184 #define IPLAPIIMPL(type,name,arg) extern type name arg
185 
186 
188  iplCreateConvKernel,(int nCols, int nRows,
189  int anchorX, int anchorY,
190  int* values, int nShiftR));
191 
193  iplCreateConvKernelFP,(int nCols, int nRows,
194  int anchorX, int anchorY, float* values));
195 
197  (IplConvKernel* kernel, int* nCols, int* nRows,
198  int* anchorX, int* anchorY, int** values, int *nShiftR));
199 
200 
202  (IplConvKernelFP* kernel,int* nCols, int* nRows,
203  int* anchorX, int* anchorY, float** values));
204 
206 
208 
210  (IplImage* srcImage, IplImage* dstImage,
211  IplConvKernel** kernel, int nKernels, int combineMethod));
212 
214  (IplImage* srcImage, IplImage* dstImage,
215  IplConvKernelFP** kernel, int nKernels, int combineMethod));
216 
217 IPLAPIIMPL(void, iplConvolveSep2DFP,(IplImage* srcImage,
218  IplImage* dstImage,
219  IplConvKernelFP* xKernel,
220  IplConvKernelFP* yKernel));
221 
222 //IPLAPIIMPL(IPLStatus, iplFixedFilter,(IplImage* srcImage, IplImage* dstImage,
223 // IplFilter filter));
224 
225 IPLAPIIMPL(void, iplConvolveSep2D,(IplImage* srcImage, IplImage* dstImage,
226  IplConvKernel* xKernel, IplConvKernel* yKernel));
227 
228 IPLAPIIMPL(void, iplAllocateImage,(IplImage* image, int doFill, int fillValue));
229 
230 IPLAPIIMPL(void, iplAllocateImageFP,(IplImage* image, int doFill, float fillValue));
231 
232 
233 IPLAPIIMPL(void, iplDeallocateImage,(IplImage* image));
234 
236  (int nChannels, int alphaChannel, int depth,
237  char* colorModel, char* channelSeq, int dataOrder,
238  int origin, int align,
239  int width, int height, IplROI* roi, IplImage* maskROI,
240  void* imageId, IplTileInfo* tileInfo));
241 
242 IPLAPIIMPL(IplImage*, iplCloneImage, ( const IplImage* img ) );
243 
244 IPLAPIIMPL(void, iplCopy, (IplImage* srcImage, IplImage* dstImage));
245 
246 IPLAPIIMPL(void, iplDeallocateHeader,(IplImage* image));
247 
248 IPLAPIIMPL(void, iplDeallocate,(IplImage* image, int flag));
249 
250 IPLAPIIMPL(void,iplSetBorderMode,(IplImage *src,int mode,int border,int constVal));
251 
252 IPLAPIIMPL(void, iplSet, (IplImage* image, int fillValue));
253 
254 IPLAPIIMPL(void, iplSetFP, (IplImage* image, float fillValue));
255 
256 IPLAPIIMPL(void, iplAddS,(IplImage* srcImage, IplImage* dstImage, int value));
257 
258 IPLAPIIMPL(void, iplAdd,(IplImage* srcImageA, IplImage* srcImageB,
259  IplImage* dstImage));
260 
261 IPLAPIIMPL(void, iplSubtract,(IplImage* srcImageA, IplImage* srcImageB,
262  IplImage* dstImage));
263 
264 IPLAPIIMPL(void, iplSubtractS,(IplImage* srcImage, IplImage* dstImage, int value,
265  bool flip));
266 
267 IPLAPIIMPL(void, iplMultiplySFP,(IplImage* srcImage, IplImage* dstImage,
268  float value));
269 
270 IPLAPIIMPL(void, iplAbs,(IplImage* srcImage, IplImage* dstImage));
271 
272 IPLAPIIMPL(void, iplThreshold, (IplImage* srcImage, IplImage* dstImage, int threshold));
273 
274 IPLAPIIMPL(void, iplColorToGray,(IplImage* srcImage, IplImage* dstImage));
275 
276 IPLAPIIMPL(IplROI *,iplCreateROI,(int coi, int xOffset, int yOffset,
277  int width, int height ));
278 
279 
280 IPLAPIIMPL(void, iplRGB2HSV,(IplImage* rgbImage, IplImage* hsvImage));
281 
282 IPLAPIIMPL(void, iplHSV2RGB,(IplImage* hsvImage, IplImage* rgbImage));
283 
284 
285 IPLAPIIMPL(void, iplXorS,(IplImage* srcImage, IplImage* dstImage, unsigned int value));
286 
287 #define IPL_BORDER_CONSTANT 0
288 
289 #define IPL_SIDE_TOP_INDEX 0
290 #define IPL_SIDE_BOTTOM_INDEX 1
291 #define IPL_SIDE_LEFT_INDEX 2
292 #define IPL_SIDE_RIGHT_INDEX 3
293 #define IPL_SIDE_TOP (1<<IPL_SIDE_TOP_INDEX)
294 #define IPL_SIDE_BOTTOM (1<<IPL_SIDE_BOTTOM_INDEX)
295 #define IPL_SIDE_LEFT (1<<IPL_SIDE_LEFT_INDEX)
296 #define IPL_SIDE_RIGHT (1<<IPL_SIDE_RIGHT_INDEX)
297 #define IPL_SIDE_ALL (IPL_SIDE_RIGHT|IPL_SIDE_TOP|IPL_SIDE_LEFT|IPL_SIDE_BOTTOM)
298 
299 #define IPL_DEPTH_MASK 0x7FFFFFFF
300 
301 #define IPL_IMAGE_HEADER 1
302 #define IPL_IMAGE_DATA 2
303 #define IPL_IMAGE_ROI 4
304 #define IPL_IMAGE_TILE 8
305 #define IPL_IMAGE_MASK 16
306 #define IPL_IMAGE_ALL (IPL_IMAGE_HEADER|IPL_IMAGE_DATA|\
307  IPL_IMAGE_TILE|IPL_IMAGE_ROI|IPL_IMAGE_MASK)
308 #define IPL_IMAGE_ALL_WITHOUT_MASK (IPL_IMAGE_HEADER|IPL_IMAGE_DATA|\
309  IPL_IMAGE_TILE|IPL_IMAGE_ROI)
310 
311 #define IPL_INTER_NN 0
312 #define IPL_INTER_LINEAR 1
313 #define IPL_INTER_CUBIC 2
314 #define IPL_INTER_SUPER 3
315 #define IPL_SMOOTH_EDGE 16
316 
317 #define YARP_IMAGE_ALIGN 8
318 
319 #endif /*YARP_CVTYPES_H_*/
320 #endif /*HAVE_OPENCV*/
321 #endif /*HAVE_IPL*/
322 #endif /*_CV_H_*/
323 
324 /* End of file. */
iplAbs
void iplAbs(IplImage *srcImage, IplImage *dstImage)
Definition: IplImage.cpp:1235
_IplImage::imageId
void * imageId
must be NULL
Definition: IplImage.h:103
_IplConvKernel::anchorX
int anchorX
Definition: IplImage.h:133
_IplConvKernelFP::nRows
int nRows
Definition: IplImage.h:143
_IplROI
Definition: IplImage.h:120
iplRGB2HSV
void iplRGB2HSV(IplImage *rgbImage, IplImage *hsvImage)
Definition: IplImage.cpp:1353
_IplImage::tileInfo
struct _IplTileInfo * tileInfo
must be null
Definition: IplImage.h:104
_IplImage::channelSeq
char channelSeq[4]
ignored by OpenCV
Definition: IplImage.h:92
_IplImage::alphaChannel
int alphaChannel
ignored by OpenCV
Definition: IplImage.h:88
iplSet
void iplSet(IplImage *image, int fillValue)
Definition: IplImage.cpp:933
_IplConvKernel
Definition: IplImage.h:130
_IplImage::maskROI
struct _IplImage * maskROI
must be NULL
Definition: IplImage.h:102
uint64
unsigned long long uint64
Definition: IplImage.h:39
iplDeleteConvKernelFP
void iplDeleteConvKernelFP(IplConvKernelFP *kernel)
Definition: IplImage.cpp:160
iplConvolveSep2D
void iplConvolveSep2D(IplImage *srcImage, IplImage *dstImage, IplConvKernel *xKernel, IplConvKernel *yKernel)
Definition: IplImage.cpp:497
_IplImage::imageDataOrigin
char * imageDataOrigin
pointer to very origin of image data (not necessarily aligned) - needed for correct deallocation
Definition: IplImage.h:112
_IplConvKernelFP::anchorX
int anchorX
Definition: IplImage.h:144
iplThreshold
void iplThreshold(IplImage *srcImage, IplImage *dstImage, int threshold)
Definition: IplImage.cpp:1268
uchar
unsigned char uchar
Definition: IplImage.h:43
iplAllocateImageFP
void iplAllocateImageFP(IplImage *image, int doFill, float fillValue)
Definition: IplImage.cpp:694
_IplROI::height
int height
Definition: IplImage.h:125
_IplROI::width
int width
Definition: IplImage.h:124
iplAllocateImage
void iplAllocateImage(IplImage *image, int doFill, int fillValue)
Definition: IplImage.cpp:661
_IplImage::imageData
char * imageData
pointer to aligned image data
Definition: IplImage.h:108
_IplConvKernel::nCols
int nCols
Definition: IplImage.h:131
_IplImage::BorderConst
int BorderConst[4]
ignored by OpenCV
Definition: IplImage.h:111
IplImage
struct _IplImage IplImage
_IplImage::roi
struct _IplROI * roi
image ROI.
Definition: IplImage.h:101
iplConvolve2D
void iplConvolve2D(IplImage *srcImage, IplImage *dstImage, IplConvKernel **kernel, int nKernels, int combineMethod)
Definition: IplImage.cpp:172
iplConvolveSep2DFP
void iplConvolveSep2DFP(IplImage *srcImage, IplImage *dstImage, IplConvKernelFP *xKernel, IplConvKernelFP *yKernel)
Definition: IplImage.cpp:389
_IplROI::xOffset
int xOffset
Definition: IplImage.h:122
int64
long long int64
Definition: IplImage.h:38
_IplImage::nChannels
int nChannels
Most of OpenCV functions support 1,2,3 or 4 channels.
Definition: IplImage.h:87
iplSubtract
void iplSubtract(IplImage *srcImageA, IplImage *srcImageB, IplImage *dstImage)
Definition: IplImage.cpp:1084
iplAdd
void iplAdd(IplImage *srcImageA, IplImage *srcImageB, IplImage *dstImage)
Definition: IplImage.cpp:1010
_IplImage::BorderMode
int BorderMode[4]
ignored by OpenCV
Definition: IplImage.h:110
_IplROI::yOffset
int yOffset
Definition: IplImage.h:123
iplMultiplySFP
void iplMultiplySFP(IplImage *srcImage, IplImage *dstImage, float value)
Definition: IplImage.cpp:1220
iplCreateImageHeader
IplImage * iplCreateImageHeader(int nChannels, int alphaChannel, int depth, char *colorModel, char *channelSeq, int dataOrder, int origin, int align, int width, int height, IplROI *roi, IplImage *maskROI, void *imageId, IplTileInfo *tileInfo)
Definition: IplImage.cpp:786
iplGetConvKernelFP
void iplGetConvKernelFP(IplConvKernelFP *kernel, int *nCols, int *nRows, int *anchorX, int *anchorY, float **values)
Definition: IplImage.cpp:139
iplCloneImage
IplImage * iplCloneImage(const IplImage *img)
Definition: IplImage.cpp:848
_IplConvKernel::values
int * values
Definition: IplImage.h:135
iplDeleteConvKernel
void iplDeleteConvKernel(IplConvKernel *kernel)
Definition: IplImage.cpp:151
iplDeallocate
void iplDeallocate(IplImage *image, int flag)
Definition: IplImage.cpp:900
IplTileInfo
struct _IplTileInfo IplTileInfo
Definition: IplImage.h:118
_IplConvKernelFP::anchorY
int anchorY
Definition: IplImage.h:145
iplXorS
void iplXorS(IplImage *srcImage, IplImage *dstImage, unsigned int value)
Definition: IplImage.cpp:1458
IplConvKernelFP
struct _IplConvKernelFP IplConvKernelFP
iplGetConvKernel
void iplGetConvKernel(IplConvKernel *kernel, int *nCols, int *nRows, int *anchorX, int *anchorY, int **values, int *nShiftR)
Definition: IplImage.cpp:125
_IplImage::colorModel
char colorModel[4]
ignored by OpenCV
Definition: IplImage.h:91
_IplImage::imageSize
int imageSize
image data size in bytes (==image->height*image->widthStep in case of interleaved data)
Definition: IplImage.h:105
iplAddS
void iplAddS(IplImage *srcImage, IplImage *dstImage, int value)
Definition: IplImage.cpp:952
iplCopy
void iplCopy(IplImage *srcImage, IplImage *dstImage)
Definition: IplImage.cpp:879
_iplCalcPadding
int _iplCalcPadding(int lineSize, int align)
Computes the ipl image padding.
Definition: IplImage.cpp:1466
IPLAPIIMPL
#define IPLAPIIMPL(type, name, arg)
Definition for functions implemented within YARP_sig.
Definition: IplImage.h:183
iplCreateConvKernel
IplConvKernel * iplCreateConvKernel(int nCols, int nRows, int anchorX, int anchorY, int *values, int nShiftR)
WARNING: most of this is implemented for PAD_BYTES == 0.
Definition: IplImage.cpp:80
_IplImage
Definition: IplImage.h:84
_IplImage::dataOrder
int dataOrder
0 - interleaved color channels, 1 - separate color channels.
Definition: IplImage.h:93
_IplConvKernel::nShiftR
int nShiftR
Definition: IplImage.h:136
_IplImage::width
int width
image width in pixels
Definition: IplImage.h:99
iplSubtractS
void iplSubtractS(IplImage *srcImage, IplImage *dstImage, int value, bool flip)
Definition: IplImage.cpp:1157
IplROI
struct _IplROI IplROI
_IplImage::nSize
int nSize
sizeof(IplImage)
Definition: IplImage.h:85
iplSetFP
void iplSetFP(IplImage *image, float fillValue)
Definition: IplImage.cpp:940
iplDeallocateImage
void iplDeallocateImage(IplImage *image)
Definition: IplImage.cpp:731
_IplConvKernelFP::nCols
int nCols
Definition: IplImage.h:142
iplCreateROI
IplROI * iplCreateROI(int coi, int xOffset, int yOffset, int width, int height)
Definition: IplImage.cpp:1337
_IplImage::depth
int depth
pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_...
Definition: IplImage.h:89
IplConvKernel
struct _IplConvKernel IplConvKernel
iplDeallocateHeader
void iplDeallocateHeader(IplImage *image)
Definition: IplImage.cpp:885
_IplConvKernelFP::values
float * values
Definition: IplImage.h:146
iplCreateConvKernelFP
IplConvKernelFP * iplCreateConvKernelFP(int nCols, int nRows, int anchorX, int anchorY, float *values)
Definition: IplImage.cpp:108
iplSetBorderMode
void iplSetBorderMode(IplImage *src, int mode, int border, int constVal)
Definition: IplImage.cpp:922
iplHSV2RGB
void iplHSV2RGB(IplImage *hsvImage, IplImage *rgbImage)
Definition: IplImage.cpp:1451
_IplConvKernel::anchorY
int anchorY
Definition: IplImage.h:134
_IplConvKernel::nRows
int nRows
Definition: IplImage.h:132
iplColorToGray
void iplColorToGray(IplImage *srcImage, IplImage *dstImage)
Definition: IplImage.cpp:1312
_IplImage::height
int height
image height in pixels
Definition: IplImage.h:100
_IplImage::widthStep
int widthStep
size of aligned image row in bytes
Definition: IplImage.h:109
_IplImage::origin
int origin
0 - top-left origin, 1 - bottom-left origin (Windows bitmaps style)
Definition: IplImage.h:95
_IplImage::align
int align
Alignment of image rows (4 or 8).
Definition: IplImage.h:97
iplConvolve2DFP
void iplConvolve2DFP(IplImage *srcImage, IplImage *dstImage, IplConvKernelFP **kernel, int nKernels, int combineMethod)
Definition: IplImage.cpp:286
_IplROI::coi
int coi
0 - no COI (all channels are selected), 1 - 0th channel is selected ...
Definition: IplImage.h:121
_IplConvKernelFP
Definition: IplImage.h:141
_IplImage::ID
int ID
version (=0)
Definition: IplImage.h:86