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