YARP
Yet Another Robot Platform
IplImage.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <cstdio>
8#include <cstring>
9
10#include <yarp/os/Log.h>
12
13// this was from iplUtil.cpp
15{
16 if (A->nChannels == B->nChannels && !strcmp(A->colorModel, B->colorModel) && !strcmp(A->channelSeq, B->channelSeq) && A->width == B->width
17 && A->height == B->height) {
18 return true;
19 } else {
20 return false;
21 }
22}
23
26inline int PAD_BYTES (int len, int pad)
27{
28 const int rem = len % pad;
29 return (rem != 0) ? (pad - rem) : 0;
30}
31
32template <class T>
33T* AllocAligned (int size)
34{
35 T *ptr = new T[size + YARP_IMAGE_ALIGN];
36 const int rem = (((size_t)ptr) % YARP_IMAGE_ALIGN);
37 const char addbytes = YARP_IMAGE_ALIGN - rem;
39
40 char *p = ((char *)ptr) + addbytes;
41 *(p - 1) = addbytes;
42 return reinterpret_cast<T*>(p);
43}
44
45template <class T>
46void FreeAligned (T* ptr)
47{
48 if (ptr == nullptr) {
49 return;
50 }
51
52 const char addbytes = *(((char *)ptr) - 1);
53 delete[] reinterpret_cast<T*>(((char *)ptr) - addbytes);
54}
55
67
68/*
69 typedef struct _IplConvKernel {
70 int nCols;
71 int nRows;
72 int anchorX;
73 int anchorY;
74 int *values;
75 int nShiftR;
76 } IplConvKernel;
77*/
78
79IPLAPIIMPL(IplConvKernel*, iplCreateConvKernel,(int nCols, int nRows,
80 int anchorX, int anchorY, int* values, int nShiftR))
81{
82 auto* ret = new IplConvKernel;
83 yAssert(ret != nullptr);
84
85 ret->anchorX = anchorX;
86 ret->anchorY = anchorY;
87 ret->nCols = nCols;
88 ret->nRows = nRows;
89 ret->nShiftR = nShiftR;
90 ret->values = new int[nCols * nRows];
91 yAssert(ret->values != nullptr);
92 memcpy (ret->values, values, sizeof(int) * nCols * nRows);
93
94 return ret;
95}
96
97/*
98 typedef struct _IplConvKernelFP {
99 int nCols;
100 int nRows;
101 int anchorX;
102 int anchorY;
103 float *values;
104 } IplConvKernelFP;
105*/
106
107IPLAPIIMPL(IplConvKernelFP*, iplCreateConvKernelFP,(int nCols, int nRows,
108 int anchorX, int anchorY, float* values))
109{
110 auto* ret = new IplConvKernelFP;
111 yAssert(ret != nullptr);
112
113 ret->anchorX = anchorX;
114 ret->anchorY = anchorY;
115 ret->nCols = nCols;
116 ret->nRows = nRows;
117 ret->values = new float[nCols * nRows];
118 yAssert(ret->values != nullptr);
119 memcpy (ret->values, values, sizeof(float) * nCols * nRows);
120
121 return ret;
122}
123
124IPLAPIIMPL(void,iplGetConvKernel,(IplConvKernel* kernel, int* nCols, int* nRows,
125 int* anchorX, int* anchorY, int** values, int *nShiftR))
126{
127 yAssert(kernel != nullptr);
128 yAssert(kernel->values != nullptr);
129
130 *nCols = kernel->nCols;
131 *nRows = kernel->nRows;
132 *anchorX = kernel->anchorX;
133 *anchorY = kernel->anchorY;
134 memcpy (*values, kernel->values, sizeof(int) * *nCols * *nRows);
135 *nShiftR = kernel->nShiftR;
136}
137
138IPLAPIIMPL(void,iplGetConvKernelFP,(IplConvKernelFP* kernel,int* nCols, int* nRows,
139 int* anchorX, int* anchorY, float** values))
140{
141 yAssert(kernel != nullptr);
142 yAssert(kernel->values != nullptr);
143
144 *nCols = kernel->nCols;
145 *nRows = kernel->nRows;
146 *anchorX = kernel->anchorX;
147 *anchorY = kernel->anchorY;
148 memcpy (*values, kernel->values, sizeof(float) * *nCols * *nRows);
149}
150
152{
153 if (kernel == nullptr) {
154 return;
155 }
156
157 delete[] kernel->values;
158 delete kernel;
159}
160
162{
163 if (kernel == nullptr) {
164 return;
165 }
166
167 delete[] kernel->values;
168 delete kernel;
169}
170
171// implemented for mono img. only.
172// TODO: in place stuff.
173IPLAPIIMPL(void, iplConvolve2D,(IplImage* srcImage, IplImage* dstImage,
174 IplConvKernel** kernel, int nKernels, int combineMethod))
175{
176 static char *__tmp_res = nullptr;
177 static int __tmp_size = -1;
178
179 yAssert(nKernels == 1);
180 // implemented only 1 kernel.
181
182 // do not consider anchor, borders are not set, and assumes
183 // that the kernel has odd dimensions (both x and y).
184
185 IplConvKernel *ktmp = *kernel;
186 int *values = ktmp->values;
187 const int ksize = ktmp->nCols * ktmp->nRows;
188
189 yAssert((ktmp->nCols % 2) != 0);
190 yAssert((ktmp->nRows % 2) != 0);
191
192 const int krows = ktmp->nRows;
193 const int kcols = ktmp->nCols;
194 const int borderx = kcols / 2;
195 const int bordery = krows / 2;
196 const int w = srcImage->width;
197 const int h = srcImage->height;
198
199 yAssert(compareHeader (srcImage, dstImage));
200 yAssert(srcImage->nChannels == 1); // Mono images only.
201
202 if (__tmp_res == nullptr)
203 {
204 __tmp_size = dstImage->imageSize;
206 __tmp_res = AllocAligned<char> (dstImage->imageSize);
207 yAssert(__tmp_res != nullptr);
208 }
209 else
210 {
211 if (__tmp_size < dstImage->imageSize)
212 {
213 // new size.
214 FreeAligned<char> (__tmp_res);
216 __tmp_size = dstImage->imageSize;
218 __tmp_res = AllocAligned<char> (dstImage->imageSize);
219 yAssert(__tmp_res != nullptr);
220 }
221 }
222
223 switch (srcImage->depth)
224 {
225 case IPL_DEPTH_8U:
226 {
227 int tmp;
228 for (int i = bordery; i < h - bordery; i++)
229 {
230 for (int j = borderx; j < w - borderx; j++)
231 {
232 tmp = 0;
233 for (int k = 0; k < krows; k++) {
234 for (int l = 0; l < kcols; l++)
235 {
236 tmp += srcImage->imageData[(i + k - bordery) * w + j + l - borderx]
237 * values[ksize - k * kcols - l - 1];
238 }
239 }
240 tmp >>= ktmp->nShiftR;
241 if (tmp > 255) {
242 tmp = 255;
243 } else if (tmp < 0) {
244 tmp = 0;
245 }
246 __tmp_res[i * w + j] = char(tmp);
247 }
248 }
249
250 memcpy (dstImage->imageData, __tmp_res, dstImage->imageSize);
251 }
252 break;
253
254 case IPL_DEPTH_8S:
255 {
256 int tmp;
257 for (int i = bordery; i < h - bordery; i++)
258 {
259 for (int j = borderx; j < w - borderx; j++)
260 {
261 tmp = 0;
262 for (int k = 0; k < krows; k++) {
263 for (int l = 0; l < kcols; l++)
264 {
265 tmp += srcImage->imageData[(i + k - bordery) * w + j + l - borderx]
266 * values[ksize - k * kcols - l - 1];
267 }
268 }
269 tmp >>= ktmp->nShiftR;
270 if (tmp > 127) {
271 tmp = 127;
272 } else if (tmp < -128) {
273 tmp = -128;
274 }
275 __tmp_res[i * w + j] = char(tmp);
276 }
277 }
278
279 memcpy (dstImage->imageData, __tmp_res, dstImage->imageSize);
280 }
281 break;
282 }
283}
284
285// Implemented for mono images only.
286// LATER: extend to color.
287// TODO: allow inplace operation.
288// combineMethod is not used because only 1 kernel is allowed.
289IPLAPIIMPL(void, iplConvolve2DFP,(IplImage* srcImage, IplImage* dstImage,
290 IplConvKernelFP** kernel, int nKernels, int combineMethod))
291{
292 // INPLACE: the first time it need to allocate the wk array.
293 // I do not really like this solution, it would be much better to
294 // alloc the array together with the Kernel.
295 // clearly this is also a memory LEAK!
296 static float *__tmp_res = nullptr;
297 static int __tmp_size = -1;
298
299 yAssert(nKernels == 1);
300 // implemented only 1 kernel.
301
302 // do not consider anchor, borders are not set, and assumes
303 // that the kernel has odd dimensions (both x and y).
304
305 IplConvKernelFP *ktmp = *kernel;
306 float *values = ktmp->values;
307 const int ksize = ktmp->nCols * ktmp->nRows;
308
309 yAssert((ktmp->nCols % 2) != 0);
310 yAssert((ktmp->nRows % 2) != 0);
311
312 const int kcols = ktmp->nCols;
313 const int krows = ktmp->nRows;
314 const int borderx = kcols / 2;
315 const int bordery = krows / 2;
316 const int w = srcImage->width;
317 const int h = srcImage->height;
318
319 yAssert(compareHeader (srcImage, dstImage));
320 yAssert(srcImage->nChannels == 1); // Mono images only.
321 yAssert(srcImage->depth == IPL_DEPTH_32F);
322
323 if (__tmp_res == nullptr)
324 {
325 __tmp_size = dstImage->imageSize / sizeof(float);
327 __tmp_res = AllocAligned<float> (dstImage->imageSize / sizeof(float));
328 yAssert(__tmp_res != nullptr);
329 }
330 else
331 {
332 if (__tmp_size < (int)(dstImage->imageSize / sizeof(float)))
333 {
334 // new size.
336 FreeAligned<float> (__tmp_res);
337 __tmp_size = dstImage->imageSize / sizeof(float);
339 __tmp_res = AllocAligned<float> (dstImage->imageSize / sizeof(float));
340 yAssert(__tmp_res != nullptr);
341 }
342 }
343
344 if (srcImage != dstImage)
345 {
346 float tmp;
347 auto* source = reinterpret_cast<float*>(srcImage->imageData);
348 auto* dest = reinterpret_cast<float*>(dstImage->imageData);
349 for (int i = bordery; i < h - bordery; i++)
350 {
351 for (int j = borderx; j < w - borderx; j++)
352 {
353 tmp = 0;
354 for (int k = 0; k < krows; k++) {
355 for (int l = 0; l < kcols; l++)
356 {
357 tmp += source[(i + k - bordery) * w + j + l - borderx]
358 * values[ksize - k * kcols - l - 1];
359 }
360 }
361 dest[i * w + j] = tmp;
362 }
363 }
364 }
365 else
366 {
367 // inplace.
368 float tmp;
369 auto* source = reinterpret_cast<float*>(srcImage->imageData);
370 //float *dest = reinterpret_cast<float*>(dstImage->imageData);
371 for (int i = bordery; i < h - bordery; i++)
372 {
373 for (int j = borderx; j < w - borderx; j++)
374 {
375 tmp = 0;
376 for (int k = 0; k < krows; k++) {
377 for (int l = 0; l < kcols; l++)
378 {
379 tmp += source[(i + k - bordery) * w + j + l - borderx]
380 * values[ksize - k * kcols - l - 1];
381 }
382 }
383 __tmp_res[i * w + j] = tmp;
384 }
385 }
386
387 memcpy (dstImage->imageData, __tmp_res, dstImage->imageSize);
388 }
389}
390
391// TODO: inplace operation.
392IPLAPIIMPL(void, iplConvolveSep2DFP,(IplImage* srcImage,
393 IplImage* dstImage,
394 IplConvKernelFP* xKernel,
396{
397 // here too I need memory to support inplace operations.
398 static float *__tmp_res = nullptr;
399 static int __tmp_size = -1;
400
401 if (xKernel != nullptr)
402 {
403 yAssert(xKernel->nRows == 1);
404 yAssert((xKernel->nCols % 2) != 0);
405 }
406 if (yKernel != nullptr)
407 {
408 yAssert(yKernel->nCols == 1);
409 yAssert((yKernel->nRows % 2) != 0);
410 }
411
412 // do not consider anchor, borders are not set, and assumes
413 // that the kernel has odd dimensions (x only).
414 float *xvalues = (xKernel != nullptr) ? xKernel->values : nullptr;
415 const int xksize = (xKernel != nullptr) ? xKernel->nCols : 0;
416 float *yvalues = (yKernel != nullptr) ? yKernel->values : nullptr;
417 const int yksize = (yKernel != nullptr) ? yKernel->nRows : 0;
418
419 const int borderx = (xKernel != nullptr) ? xKernel->nCols / 2 : 0;
420 const int bordery = (yKernel != nullptr) ? yKernel->nRows / 2 : 0;
421 const int w = srcImage->width;
422 const int h = srcImage->height;
423
424 yAssert(compareHeader (srcImage, dstImage));
425 yAssert(srcImage->nChannels == 1); // Mono images only.
426 yAssert(srcImage->depth == IPL_DEPTH_32F);
427
428 if (__tmp_res == nullptr)
429 {
430 __tmp_size = dstImage->imageSize / sizeof(float);
432 __tmp_res = AllocAligned<float> (dstImage->imageSize / sizeof(float));
433 yAssert(__tmp_res != nullptr);
434 }
435 else
436 {
437 if (__tmp_size < int(dstImage->imageSize / sizeof(float)))
438 {
439 // new size.
441 FreeAligned<float> (__tmp_res);
442 __tmp_size = dstImage->imageSize / sizeof(float);
444 __tmp_res = AllocAligned<float> (dstImage->imageSize / sizeof(float));
445 yAssert(__tmp_res != nullptr);
446 }
447 }
448
449 // inplace.
450 auto* src = reinterpret_cast<float*>(srcImage->imageData);
451 auto* dst = reinterpret_cast<float*>(dstImage->imageData);
452 if (xKernel != nullptr)
453 {
454 // apply x kernel.
455 float tmp;
456 for (int i = 0; i < h; i++)
457 {
458 for (int j = borderx; j < w - borderx; j++)
459 {
460 tmp = 0;
461 for (int k = 0; k < xksize; k++)
462 {
463 tmp += src[i * w + j + k - borderx]
464 * xvalues[xksize - k - 1];
465 }
466 __tmp_res[i * w + j] = tmp;
467 }
468 }
469 }
470
471 if (yKernel != nullptr)
472 {
473 // apply y kernel.
474 float tmp;
475 for (int i = bordery; i < h - bordery; i++)
476 {
477 // can save borderx (if applied)!
478 for (int j = borderx; j < w - borderx; j++)
479 {
480 tmp = 0;
481 for (int k = 0; k < yksize; k++)
482 {
483 tmp += __tmp_res[(i + k - bordery) * w + j]
484 * yvalues[yksize - k - 1];
485 }
486 dst[i * w + j] = tmp;
487 }
488 }
489 }
490}
491
492/*
493 IPLAPIIMPL(IPLStatus, iplFixedFilter,(IplImage* srcImage, IplImage* dstImage,
494 IplFilter filter))
495 {
496 // NOT IMPLEMENTED YET.
497 yAssert(false);
498 return -1;
499 }
500*/
501
502IPLAPIIMPL(void, iplConvolveSep2D,(IplImage* srcImage, IplImage* dstImage,
503 IplConvKernel* xKernel, IplConvKernel* yKernel))
504{
505 // in place stuff.
506 static char *__tmp_res = nullptr;
507 static int __tmp_size = -1;
508
509 if (xKernel != nullptr)
510 {
511 yAssert(xKernel->nRows == 1);
512 yAssert((xKernel->nCols % 2) != 0);
513 }
514 if (yKernel != nullptr)
515 {
516 yAssert(yKernel->nCols == 1);
517 yAssert((yKernel->nRows % 2) != 0);
518 }
519
520 // do not consider anchor, borders are not set, and assumes
521 // that the kernel has odd dimensions (x only).
522 int *xvalues = (xKernel != nullptr) ? xKernel->values : nullptr;
523 const int xksize = (xKernel != nullptr) ? xKernel->nCols : 0;
524 int *yvalues = (yKernel != nullptr) ? yKernel->values : nullptr;
525 const int yksize = (yKernel != nullptr) ? yKernel->nRows : 0;
526
527 const int borderx = (xKernel != nullptr) ? xKernel->nCols / 2 : 0;
528 const int bordery = (yKernel != nullptr) ? yKernel->nRows / 2 : 0;
529 const int w = srcImage->width;
530 const int h = srcImage->height;
531
532 yAssert(compareHeader (srcImage, dstImage));
533 yAssert(srcImage->nChannels == 1); // Mono images only.
534
535 if (__tmp_res == nullptr)
536 {
537 __tmp_size = dstImage->imageSize;
539 __tmp_res = AllocAligned<char> (dstImage->imageSize);
540 yAssert(__tmp_res != nullptr);
541 }
542 else
543 {
544 if (__tmp_size < dstImage->imageSize)
545 {
546 // new size.
547 FreeAligned<char> (__tmp_res);
549 __tmp_size = dstImage->imageSize;
551 __tmp_res = AllocAligned<char> (dstImage->imageSize);
552 yAssert(__tmp_res != nullptr);
553 }
554 }
555
556 switch (srcImage->depth)
557 {
558 case IPL_DEPTH_8U:
559 {
560 if (xKernel != nullptr)
561 {
562 // apply x kernel.
563 int tmp;
564 for (int i = 0; i < h; i++)
565 {
566 for (int j = borderx; j < w - borderx; j++)
567 {
568 tmp = 0;
569 for (int k = 0; k < xksize; k++)
570 {
571 tmp += srcImage->imageData[i * w + j + k - borderx]
572 * xvalues[xksize - k - 1];
573 }
574 tmp >>= xKernel->nShiftR;
575 if (tmp > 255) {
576 tmp = 255;
577 } else if (tmp < 0) {
578 tmp = 0;
579 }
580 __tmp_res[i * w + j] = char(tmp);
581 }
582 }
583 }
584
585 if (yKernel != nullptr)
586 {
587 // apply y kernel.
588 int tmp;
589 for (int i = bordery; i < h - bordery; i++)
590 {
591 // can save borderx (if applied)!
592 for (int j = borderx; j < w - borderx; j++)
593 {
594 tmp = 0;
595 for (int k = 0; k < yksize; k++)
596 {
597 tmp += __tmp_res[(i + k - bordery) * w + j]
598 * yvalues[yksize - k - 1];
599 }
600 tmp >>= yKernel->nShiftR;
601 if (tmp > 255) {
602 tmp = 255;
603 } else if (tmp < 0) {
604 tmp = 0;
605 }
606 dstImage->imageData[i * w + j] = char(tmp);
607 }
608 }
609 }
610 }
611 break;
612
613 case IPL_DEPTH_8S:
614 {
615 if (xKernel != nullptr)
616 {
617 int tmp;
618 for (int i = 0; i < h; i++)
619 {
620 for (int j = borderx; j < w - borderx; j++)
621 {
622 tmp = 0;
623 for (int k = 0; k < xksize; k++)
624 {
625 tmp += srcImage->imageData[i * w + j + k - borderx]
626 * xvalues[xksize - k - 1];
627 }
628 tmp >>= xKernel->nShiftR;
629 if (tmp > 127) {
630 tmp = 127;
631 } else if (tmp < -128) {
632 tmp = -128;
633 }
634 __tmp_res[i * w + j] = char(tmp);
635 }
636 }
637 }
638
639 if (yKernel != nullptr)
640 {
641 int tmp;
642 for (int i = bordery; i < h - bordery; i++)
643 {
644 for (int j = borderx; j < w - borderx; j++)
645 {
646 tmp = 0;
647 for (int k = 0; k < yksize; k++)
648 {
649 tmp += __tmp_res[(i + k - bordery) * w + j]
650 * yvalues[yksize - k - 1];
651 }
652 tmp >>= yKernel->nShiftR;
653 if (tmp > 127) {
654 tmp = 127;
655 } else if (tmp < -128) {
656 tmp = -128;
657 }
658 dstImage->imageData[i * w + j] = char(tmp);
659 }
660 }
661 }
662 }
663 }
664}
665
666// TODO: manage IPL ROI and tiling.
667IPLAPIIMPL(void, iplAllocateImage,(IplImage* image, int doFill, int fillValue))
668{
669 // Not implemented depth != 8
670 //int depth = (image->depth & IPL_DEPTH_MASK)/8;
673 yAssert(image->imageSize == image->widthStep * image->height);
674
675 image->imageData = AllocAligned<char> (image->imageSize); // new char[image->imageSize];
676 yAssert(image->imageData != nullptr);
677
678 if (image->origin == IPL_ORIGIN_TL) {
679 image->imageDataOrigin = image->imageData + image->imageSize - image->widthStep;
680 } else {
681 image->imageDataOrigin = image->imageData;
682 }
683
684 if (doFill)
685 {
686 // this of course is only valid for depth == 8.
687 switch (image->depth)
688 {
689 case IPL_DEPTH_8U:
690 case IPL_DEPTH_8S:
691 memset (image->imageData, fillValue, image->imageSize);
692 break;
693
694 default:
695 yAssert(1 == 0);
696 break;
697 }
698 }
699}
700
701IPLAPIIMPL(void, iplAllocateImageFP,(IplImage* image, int doFill, float fillValue))
702{
703 yAssert(image->depth == IPL_DEPTH_32F);
705 // yAssert(image->widthStep == image->width * (image->depth & IPL_DEPTH_MASK) / 8 * image->nChannels);
706 yAssert(image->imageSize == image->widthStep * image->height);
707
708 image->imageData = AllocAligned<char> (image->imageSize);
709 yAssert(image->imageData != nullptr);
710
711 if (image->origin == IPL_ORIGIN_TL) {
712 image->imageDataOrigin = image->imageData + image->imageSize - image->widthStep;
713 } else {
714 image->imageDataOrigin = image->imageData;
715 }
716
717 if (doFill)
718 {
719 if (fillValue == 0)
720 {
721 // assume IEEE float
722 memset (image->imageData, 0, image->imageSize);
723 }
724 else
725 {
727
728 // time consuming
729 auto* tmp = reinterpret_cast<float*>(image->imageData);
730 const int limit = image->imageSize / sizeof(float);
731 for (int i = 0; i < limit; i++)
732 {
733 *tmp++ = float(fillValue);
734 }
735 }
736 }
737}
738
740{
741 if (image->imageData != nullptr) {
742 FreeAligned<char>(image->imageData);
743 }
744 image->imageData = nullptr;
745
746 // Not allocated.
747 image->roi = nullptr;
748}
749
750
751/* /////////////////////////////////////////////////////////////////////////
752// Name: iplCreateImageHeader
753// Purpose: Creates an IPL image header according to the specified
754// attributes.
755// Returns: The newly constructed IPL image header.
756// Parameters:
757// nChannels - Number of channels in the image.
758// alphaChannel - Alpha channel number (0 if no alpha channel in image).
759// depth - Bit depth of pixels. Can be one of
760// IPL_DEPTH_1U,
761// IPL_DEPTH_8U,
762// IPL_DEPTH_8S,
763// IPL_DEPTH_16U,
764// IPL_DEPTH_16S,
765// IPL_DEPTH_32S.
766// IPL_DEPTH_32F.
767// colorModel - A four character array describing the color model,
768// e.g. "RGB", "GRAY", "MSI" etc.
769// channelSeq - The sequence of channels in the image,
770// e.g. "BGR" for an RGB image.
771// dataOrder - IPL_DATA_ORDER_PIXEL or IPL_DATA_ORDER_PLANE.
772// origin - The origin of the image.
773// Can be IPL_ORIGIN_TL or IPL_ORIGIN_BL.
774// align - Alignment of image data.
775// Can be IPL_ALIGN_4BYTES (IPL_ALIGN_DWORD) or
776// IPL_ALIGN_8BYTES (IPL_ALIGN_QWORD) or
777// IPL_ALIGN_16BYTES IPL_ALIGN_32BYTES.
778// width - Width of the image in pixels.
779// height - Height of the image in pixels.
780// roi - Pointer to an ROI (region of interest) structure.
781// This can be NULL (implying a region of interest comprising
782// all channels and the entire image area).
783// maskROI - Pointer on mask image
784// imageId - use of the application
785// tileInfo - contains information on tiling
786//
787// Notes:
788*/
789
791 (int nChannels, int alphaChannel, int depth,
792 char* colorModel, char* channelSeq, int dataOrder,
793 int origin, int align,
794 int width, int height, IplROI* roi, IplImage* maskROI,
795 void* imageId, IplTileInfo* tileInfo))
796{
797 switch (depth)
798 {
799 default:
800 case IPL_DEPTH_1U:
801 return nullptr;
802
803 case IPL_DEPTH_8U:
804 case IPL_DEPTH_8S:
805 case IPL_DEPTH_32F:
806 case IPL_DEPTH_16U:
807 case IPL_DEPTH_16S:
808 case IPL_DEPTH_32S:
809 break;
810 }
811
812 IplImage *r = nullptr;
813 r = new IplImage;
814 yAssert(r != nullptr);
815
816 r->nSize = sizeof(IplImage);
817 r->ID = 0xf0f0f0f0; // pasa's ID for IPL under QNX.
818
819 r->nChannels = nChannels;
820 r->alphaChannel = alphaChannel;
821 r->depth = depth;
822
823 memcpy (r->colorModel, colorModel, 4);
824 memcpy (r->channelSeq, channelSeq, 4);
825
826 yAssert(dataOrder == IPL_DATA_ORDER_PIXEL);
827
828 r->dataOrder = dataOrder; // IPL_DATA_ORDER_PIXEL, IPL_DATA_ORDER_PLANE
829 r->origin = origin;
830
831 //yAssert(align == IPL_ALIGN_QWORD); /// don't want to be bothered w/ alignment beside the
833 //yAssert(align == YARP_IMAGE_ALIGN);
834
835 r->align = align;
836 r->width = width;
837 r->height = height;
838 r->roi = nullptr;
839 r->maskROI = nullptr;
840 r->imageId = nullptr;
841
842 r->tileInfo = nullptr;
843 const int linew = width * (depth & IPL_DEPTH_MASK) / 8 * nChannels;
844 r->widthStep = linew + PAD_BYTES(linew, align);
845
846 r->imageSize = r->widthStep * height;
847 r->imageData = nullptr;
848 r->tileInfo = nullptr;
849
850 memset (r->BorderMode, 0, 4 * sizeof(int));
851 memset (r->BorderConst, 0, 4 * sizeof(int));
852
853 r->imageDataOrigin = nullptr;
854 return r;
855}
856
858{
860 img->nChannels, img->alphaChannel, img->depth, (char *)img->colorModel, (char *)img->channelSeq,
861 img->dataOrder, img->origin, img->align, img->width, img->height, nullptr, nullptr,
862 img->imageId, nullptr);
863
864 if (img->imageData != nullptr)
865 {
866 switch (img->depth)
867 {
868 case IPL_DEPTH_8U:
869 case IPL_DEPTH_8S:
870 iplAllocateImage (ret, 0, 0);
871 break;
872
873 case IPL_DEPTH_32F:
874 iplAllocateImageFP (ret, 0, 0.0);
875 break;
876
877 default:
878 yAssert(1 == 0);
879 break;
880 }
881
882 memcpy (ret->imageData, img->imageData, img->imageSize);
883 }
884
885 return ret;
886}
887
888IPLAPIIMPL(void, iplCopy, (IplImage* srcImage, IplImage* dstImage))
889{
890 yAssert(srcImage->imageData != nullptr && dstImage->imageData != nullptr);
891 memcpy (dstImage->imageData, srcImage->imageData, srcImage->imageSize);
892}
893
895{
896 if (image == nullptr) {
897 return;
898 }
899
900 yAssert(image->nSize == sizeof(IplImage));
901 if (image->imageData != nullptr)
902 {
903 FreeAligned<char> (image->imageData);
905 }
906
907 delete image;
908}
909
910IPLAPIIMPL(void, iplDeallocate,(IplImage* image, int flag))
911{
912 switch (flag)
913 {
915 case IPL_IMAGE_ALL:
916 case IPL_IMAGE_HEADER:
917 iplDeallocateHeader (image);
918 break;
919
920 case IPL_IMAGE_DATA:
921 iplDeallocateImage (image);
922 break;
923
924 case IPL_IMAGE_ROI:
925 case IPL_IMAGE_TILE:
926 case IPL_IMAGE_MASK:
927 // NOT IMPLEMENTED.
928 break;
929 }
930}
931
932IPLAPIIMPL(void,iplSetBorderMode,(IplImage *src,int mode,int border,int constVal))
933{
934 for (int i = 0; i < 4; i++) {
935 if ((border >> i) & 0x1)
936 {
937 src->BorderMode[i] = mode;
938 src->BorderConst[i] = constVal;
939 }
940 }
941}
942
943// this is ok only for 8 bits pixel/planes images. RGB and HSV are ok too.
944IPLAPIIMPL(void, iplSet, (IplImage* image, int fillValue))
945{
946 yAssert(image->imageData != nullptr);
947 yAssert((image->depth & IPL_DEPTH_MASK) == 8);
948 memset (image->imageData, fillValue, image->imageSize);
949}
950
951IPLAPIIMPL(void, iplSetFP, (IplImage* image, float fillValue))
952{
953 yAssert(image->imageData != nullptr);
954 yAssert(image->depth == IPL_DEPTH_32F);
955
956 const int size = image->imageSize / sizeof(float);
957 auto* tmp = reinterpret_cast<float*>(image->imageData);
958 for (int i = 0; i < size; i++) {
959 *tmp++ = fillValue;
960 }
961}
962
963// only 8 bits supported. Clipping is carried out to be ipl compatible.
964IPLAPIIMPL(void, iplAddS,(IplImage* srcImage, IplImage* dstImage, int value))
965{
966 yAssert(compareHeader (srcImage, dstImage));
967 yAssert(srcImage->depth == dstImage->depth);
968
969 // assume images have the same size and 8 bits/pixel/planes.
970 switch (srcImage->depth)
971 {
972 case IPL_DEPTH_8U:
973 {
974 const int size = srcImage->imageSize;
975 auto* src = (unsigned char *)srcImage->imageData;
976 auto* dst = (unsigned char *)dstImage->imageData;
977
978 short tmp;
979
980 for (int i = 0; i < size; i++)
981 {
982 tmp = *src++ + value;
983 if (tmp < 0) {
984 tmp = 0;
985 } else if (tmp > 255) {
986 tmp = 255;
987 }
988 *dst++ = char(tmp);
989 }
990 }
991 break;
992
993 case IPL_DEPTH_8S:
994 {
995 const int size = srcImage->imageSize;
996 char * src = srcImage->imageData;
997 char * dst = dstImage->imageData;
998
999 short tmp;
1000
1001 for (int i = 0; i < size; i++)
1002 {
1003 tmp = *src++ + value;
1004 if (tmp < -128) {
1005 tmp = -128;
1006 } else if (tmp > 127) {
1007 tmp = 127;
1008 }
1009 *dst++ = char(tmp);
1010 }
1011 }
1012 break;
1013
1014 default:
1015 yAssert(1 == 0);
1016 // NOT IMPLEMENTED.
1017 break;
1018 }
1019}
1020
1021IPLAPIIMPL(void, iplAdd,(IplImage* srcImageA, IplImage* srcImageB,
1022 IplImage* dstImage))
1023{
1024 yAssert(compareHeader (srcImageA, srcImageB));
1025 yAssert(compareHeader (srcImageB, dstImage));
1026
1027 yAssert(srcImageA->depth == srcImageB->depth);
1028 yAssert(srcImageA->depth == dstImage->depth);
1029
1030 // assume images have the same size and 8 bits/pixel/planes.
1031 switch (srcImageA->depth)
1032 {
1033 case IPL_DEPTH_8U:
1034 {
1035 const int size = srcImageA->imageSize;
1036 auto* src1 = (unsigned char *)srcImageA->imageData;
1037 auto* src2 = (unsigned char *)srcImageB->imageData;
1038 auto* dst = (unsigned char *)dstImage->imageData;
1039
1040 short tmp;
1041
1042 for (int i = 0; i < size; i++)
1043 {
1044 tmp = *src1++ + *src2++;
1045 if (tmp > 255) {
1046 tmp = 255;
1047 }
1048 *dst++ = char(tmp);
1049 }
1050 }
1051 break;
1052
1053 case IPL_DEPTH_8S:
1054 {
1055 const int size = srcImageA->imageSize;
1056 char * src1 = srcImageA->imageData;
1057 char * src2 = srcImageB->imageData;
1058 char * dst = dstImage->imageData;
1059
1060 short tmp;
1061
1062 for (int i = 0; i < size; i++)
1063 {
1064 tmp = *src1++ + *src2++;
1065 if (tmp < -128) {
1066 tmp = -128;
1067 } else if (tmp > 127) {
1068 tmp = 127;
1069 }
1070 *dst++ = char(tmp);
1071 }
1072 }
1073 break;
1074
1075 case IPL_DEPTH_32F:
1076 {
1077 const int size = srcImageA->imageSize / sizeof(float);
1078 auto* src1 = reinterpret_cast<float*>(srcImageA->imageData);
1079 auto* src2 = reinterpret_cast<float*>(srcImageB->imageData);
1080 auto* dst = reinterpret_cast<float*>(dstImage->imageData);
1081
1082 for (int i = 0; i < size; i++)
1083 {
1084 *dst++ = *src1++ + *src2++;
1085 }
1086 }
1087 break;
1088
1089 default:
1090 yAssert(1 == 0);
1091 // NOT IMPLEMENTED.
1092 break;
1093 }
1094}
1095
1096IPLAPIIMPL(void, iplSubtract,(IplImage* srcImageA, IplImage* srcImageB,
1097 IplImage* dstImage))
1098{
1099 yAssert(compareHeader (srcImageA, srcImageB));
1100 yAssert(compareHeader (srcImageB, dstImage));
1101
1102 // assume images have the same size and 8 bits/pixel/planes.
1103 switch (srcImageA->depth)
1104 {
1105 case IPL_DEPTH_8U:
1106 {
1107 const int size = srcImageA->imageSize;
1108 auto* src1 = (unsigned char *)srcImageA->imageData;
1109 auto* src2 = (unsigned char *)srcImageB->imageData;
1110 auto* dst = (unsigned char *)dstImage->imageData;
1111
1112 short tmp;
1113
1114 for (int i = 0; i < size; i++)
1115 {
1116 tmp = *src1++ - *src2++;
1117 if (tmp < 0) {
1118 tmp = 0;
1119 }
1120 if (tmp > 255) {
1121 tmp = 255;
1122 }
1123 *dst++ = char(tmp);
1124 }
1125 }
1126 break;
1127
1128 case IPL_DEPTH_8S:
1129 {
1130 const int size = srcImageA->imageSize;
1131 char * src1 = srcImageA->imageData;
1132 char * src2 = srcImageB->imageData;
1133 char * dst = dstImage->imageData;
1134
1135 short tmp;
1136
1137 for (int i = 0; i < size; i++)
1138 {
1139 tmp = *src1++ - *src2++;
1140 if (tmp < -128) {
1141 tmp = -128;
1142 } else if (tmp > 127) {
1143 tmp = 127;
1144 }
1145 *dst++ = char(tmp);
1146 }
1147 }
1148 break;
1149
1150 case IPL_DEPTH_32F:
1151 {
1152 const int size = srcImageA->imageSize / sizeof(float);
1153 auto* src1 = reinterpret_cast<float*>(srcImageA->imageData);
1154 auto* src2 = reinterpret_cast<float*>(srcImageB->imageData);
1155 auto* dst = reinterpret_cast<float*>(dstImage->imageData);
1156
1157 for (int i = 0; i < size; i++)
1158 {
1159 *dst++ = *src1++ - *src2++;
1160 }
1161 }
1162 break;
1163
1164 default:
1165 yAssert(1 == 0);
1166 // NOT IMPLEMENTED.
1167 break;
1168 }
1169}
1170
1171IPLAPIIMPL(void, iplSubtractS,(IplImage* srcImage, IplImage* dstImage, int value,
1172 bool flip))
1173{
1174 // assume images have the same size and 8 bits/pixel/planes.
1175 switch (srcImage->depth)
1176 {
1177 case IPL_DEPTH_8U:
1178 {
1179 const int size = srcImage->imageSize;
1180 auto* src = (unsigned char *)srcImage->imageData;
1181 auto* dst = (unsigned char *)dstImage->imageData;
1182
1183 short tmp;
1184
1185 for (int i = 0; i < size; i++)
1186 {
1187 if (flip) {
1188 tmp = value - *src++;
1189 } else {
1190 tmp = *src++ - value;
1191 }
1192
1193 if (tmp < 0) {
1194 tmp = 0;
1195 } else if (tmp > 255) {
1196 tmp = 255;
1197 }
1198 *dst++ = char(tmp);
1199 }
1200 }
1201 break;
1202
1203 case IPL_DEPTH_8S:
1204 {
1205 const int size = srcImage->imageSize;
1206 char * src = srcImage->imageData;
1207 char * dst = dstImage->imageData;
1208
1209 short tmp;
1210
1211 for (int i = 0; i < size; i++)
1212 {
1213 if (flip) {
1214 tmp = value - *src++;
1215 } else {
1216 tmp = *src++ - value;
1217 }
1218
1219 if (tmp < -128) {
1220 tmp = -128;
1221 } else if (tmp > 127) {
1222 tmp = 127;
1223 }
1224 *dst++ = char(tmp);
1225 }
1226 }
1227 break;
1228
1229 default:
1230 yAssert(1 == 0);
1231 // NOT IMPLEMENTED.
1232 break;
1233 }
1234}
1235
1236IPLAPIIMPL(void, iplMultiplySFP,(IplImage* srcImage, IplImage* dstImage,
1237 float value))
1238{
1239 yAssert(compareHeader (srcImage, dstImage));
1240 yAssert(srcImage->depth == IPL_DEPTH_32F);
1241
1242 const int size = srcImage->imageSize / sizeof(float);
1243 auto* src1 = reinterpret_cast<float*>(srcImage->imageData);
1244 auto* dst = reinterpret_cast<float*>(dstImage->imageData);
1245
1246 for (int i = 0; i < size; i++)
1247 {
1248 *dst++ = *src1++ * value;
1249 }
1250}
1251
1252IPLAPIIMPL(void, iplAbs,(IplImage* srcImage, IplImage* dstImage))
1253{
1254 switch (srcImage->depth)
1255 {
1256 case IPL_DEPTH_8U:
1257 {
1258 memcpy (dstImage->imageData, srcImage->imageData, dstImage->imageSize);
1259 }
1260 break;
1261
1262 case IPL_DEPTH_8S:
1263 {
1264 const int size = srcImage->imageSize;
1265 char * src = srcImage->imageData;
1266 char * dst = dstImage->imageData;
1267
1268 for (int i = 0; i < size; i++)
1269 {
1270 if (*src < 0) {
1271 *dst++ = -*src++;
1272 } else {
1273 *dst++ = *src++;
1274 }
1275 }
1276 }
1277 break;
1278
1279 default:
1280 yAssert(1 == 0);
1281 // NOT IMPLEMENTED.
1282 break;
1283 }
1284}
1285
1286IPLAPIIMPL(void, iplThreshold, (IplImage* srcImage, IplImage* dstImage, int threshold))
1287{
1288 switch (srcImage->depth)
1289 {
1290 case IPL_DEPTH_8U:
1291 {
1292 const int size = srcImage->imageSize;
1293 auto* src = (unsigned char *)srcImage->imageData;
1294 auto* dst = (unsigned char *)dstImage->imageData;
1295
1296 for (int i = 0; i < size; i++)
1297 {
1298 if (*src++ < threshold) {
1299 *dst++ = 0;
1300 } else {
1301 *dst++ = 255;
1302 }
1303 }
1304 }
1305 break;
1306
1307 case IPL_DEPTH_8S:
1308 {
1309 const int size = srcImage->imageSize;
1310 char * src = srcImage->imageData;
1311 char * dst = dstImage->imageData;
1312
1313 for (int i = 0; i < size; i++)
1314 {
1315 if (*src++ < threshold) {
1316 *dst++ = -128;
1317 } else {
1318 *dst++ = 127;
1319 }
1320 }
1321 }
1322 break;
1323
1324 default:
1325 yAssert(1 == 0);
1326 // NOT IMPLEMENTED.
1327 break;
1328 }
1329}
1330
1331// TODO: HSV to Gray!
1332IPLAPIIMPL(void, iplColorToGray,(IplImage* srcImage, IplImage* dstImage))
1333{
1334 yAssert(srcImage->width == dstImage->width);
1335 yAssert(srcImage->height == dstImage->height);
1336 yAssert(srcImage->depth == dstImage->depth);
1337 yAssert(srcImage->depth != IPL_DEPTH_32F);
1338
1339 char *sdata = srcImage->imageData; // color
1340 char *dst = dstImage->imageData; // BW
1341
1342 const int h = dstImage->height;
1343 const int w = dstImage->width;
1344 const int size = w * h;
1345 for (int i = 0; i < size; i++)
1346 {
1347 short tmp = *sdata++;
1348 tmp += *sdata++;
1349 tmp += *sdata++;
1350 tmp /= 3;
1351
1352 *dst++ = char(tmp);
1353 }
1354}
1355
1356IPLAPIIMPL(IplROI *,iplCreateROI,(int coi, int xOffset, int yOffset,
1357 int width, int height ))
1358{
1359 // NOT IMPLEMENTED YET.
1360 yAssert(false);
1361 return nullptr;
1362}
1363
1364IPLAPIIMPL(void, iplSetROI,(IplROI* roi, int coi,
1365 int xOffset, int yOffset,
1366 int width, int height))
1367{
1368 yAssert(false);
1369}
1370
1371// LATER: image types are not checked.
1372// It should be RGB not signed.
1373IPLAPIIMPL(void, iplRGB2HSV,(IplImage* rgbImage, IplImage* hsvImage))
1374{
1375 // Image types should be checked.
1376 //const int planesize = rgbImage->widthStep * rgbImage->height;
1377 auto* sdata = (unsigned char *)rgbImage->imageData; // bgr
1378 auto* ddata0 = (unsigned char *)hsvImage->imageData; // Hue.
1379 unsigned char *ddata1 = ddata0 + 1; // Saturation.
1380 unsigned char *ddata2 = ddata1 + 1; // Value.
1381
1382 double max,min;
1383 double red,green,blue;
1384 double hue=0,sat;
1385
1386 const int width = rgbImage->width;
1387 const int height = rgbImage->height;
1388 const int size = width * height; // # of pixels.
1389
1390 for (int i = 0; i < size; i++)
1391 {
1392 blue = *sdata++ / 255.0;
1393 green = *sdata++ / 255.0;
1394 red = *sdata++ / 255.0;
1395
1396 if (red > green && red > blue)
1397 {
1398 max = red;
1399 if (green > blue) {
1400 min = blue;
1401 } else {
1402 min = green;
1403 }
1404 }
1405 else
1406 if (green > red && green > blue)
1407 {
1408 max = green;
1409 if (red > blue) {
1410 min = blue;
1411 } else {
1412 min = red;
1413 }
1414 }
1415 else
1416 {
1417 max = blue;
1418 if (red > green) {
1419 min = green;
1420 } else {
1421 min = red;
1422 }
1423 }
1424
1425 // value
1426 *ddata2 = (unsigned char)(255.0 * max);
1427 ddata2 += 3;
1428
1429 // saturation
1430 if (max != 0.0)
1431 {
1432 sat = *ddata1 = (unsigned char)(255 * (max - min) / max);
1433 } else {
1434 sat = *ddata1 = 0;
1435 }
1436 ddata1 += 3;
1437
1438 // hue
1439 if (sat == 0) {
1440 *ddata0 = 0;
1441 } else {
1442 double rc = (max - red) / (max - min);
1443 double gc = (max - green) / (max - min);
1444 double bc = (max - blue) / (max - min);
1445 if (red == max) {
1446 hue = bc - gc;
1447 } else if (green == max) {
1448 hue = 2 + rc - bc;
1449 } else if (blue == max) {
1450 hue = 4 + gc - rc;
1451 }
1452
1453 hue *= 60.0;
1454 if (hue < 0.0) {
1455 hue += 360.0;
1456 }
1457
1458 yAssert(hue >= 0.0 && hue < 360.0);
1459 // IPL 2.5 compatibility. Scaling to 0-255
1460 // there's a little chance that the value rounds to 256.0!
1461 // need clipping rather than truncation.
1462 hue = (hue / 360.0 * 256.0);
1463 if (hue == 256.0) {
1464 hue = 255.0;
1465 }
1466
1467 *ddata0 = (unsigned char)(hue);
1468 }
1469
1470 ddata0 += 3;
1471 }
1472}
1473
1474IPLAPIIMPL(void, iplHSV2RGB,(IplImage* hsvImage, IplImage* rgbImage))
1475{
1476 // NOT IMPLEMENTED YET.
1477 yAssert(false);
1478}
1479
1480IPLAPIIMPL(void, iplXorS,(IplImage* srcImage, IplImage* dstImage,
1481 unsigned int value))
1482{
1483 // NOT IMPLEMENTED YET.
1484 yAssert(false);
1485}
1486
1487// computes the number of pad bytes (end of line) give the line len and
1488// the requested alignment in byte
1489inline int _iplCalcPadding (int lineSize, int align)
1490{
1491 return PAD_BYTES (lineSize, align);
1492}
1493
1494// not used outside this file.
1495#undef IPLAPIIMPL
bool ret
T * AllocAligned(int size)
Definition: IplImage.cpp:33
void iplSubtract(IplImage *srcImageA, IplImage *srcImageB, IplImage *dstImage)
Definition: IplImage.cpp:1097
void iplDeleteConvKernelFP(IplConvKernelFP *kernel)
Definition: IplImage.cpp:161
int PAD_BYTES(int len, int pad)
this might turn out to be useful.
Definition: IplImage.cpp:26
int _iplCalcPadding(int lineSize, int align)
Computes the ipl image padding.
Definition: IplImage.cpp:1489
IplConvKernelFP * iplCreateConvKernelFP(int nCols, int nRows, int anchorX, int anchorY, float *values)
Definition: IplImage.cpp:108
void iplCopy(IplImage *srcImage, IplImage *dstImage)
Definition: IplImage.cpp:888
bool compareHeader(IplImage *A, IplImage *B)
Definition: IplImage.cpp:14
void iplHSV2RGB(IplImage *hsvImage, IplImage *rgbImage)
Definition: IplImage.cpp:1474
void iplDeleteConvKernel(IplConvKernel *kernel)
Definition: IplImage.cpp:151
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
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 iplDeallocateHeader(IplImage *image)
Definition: IplImage.cpp:894
IplROI * iplCreateROI(int coi, int xOffset, int yOffset, int width, int height)
Definition: IplImage.cpp:1357
void iplSet(IplImage *image, int fillValue)
Definition: IplImage.cpp:944
void iplConvolveSep2DFP(IplImage *srcImage, IplImage *dstImage, IplConvKernelFP *xKernel, IplConvKernelFP *yKernel)
Definition: IplImage.cpp:395
void iplColorToGray(IplImage *srcImage, IplImage *dstImage)
Definition: IplImage.cpp:1332
void iplSubtractS(IplImage *srcImage, IplImage *dstImage, int value, bool flip)
Definition: IplImage.cpp:1172
void FreeAligned(T *ptr)
Definition: IplImage.cpp:46
void iplThreshold(IplImage *srcImage, IplImage *dstImage, int threshold)
Definition: IplImage.cpp:1286
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
void iplAbs(IplImage *srcImage, IplImage *dstImage)
Definition: IplImage.cpp:1252
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
IplImage * iplCloneImage(const IplImage *img)
Definition: IplImage.cpp:857
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
void iplSetROI(IplROI *roi, int coi, int xOffset, int yOffset, int width, int height)
Definition: IplImage.cpp:1366
void iplSetFP(IplImage *image, float fillValue)
Definition: IplImage.cpp:951
void iplConvolve2D(IplImage *srcImage, IplImage *dstImage, IplConvKernel **kernel, int nKernels, int combineMethod)
Definition: IplImage.cpp:174
#define yAssert(x)
Definition: Log.h:383
#define IPLAPIIMPL(type, name, arg)
Definition for functions implemented within YARP_sig.
Definition: IplImage.h:180
#define IPL_IMAGE_MASK
Definition: IplImage.h:301
#define IPL_IMAGE_ROI
Definition: IplImage.h:299
#define IPL_IMAGE_TILE
Definition: IplImage.h:300
#define IPL_IMAGE_ALL
Definition: IplImage.h:302
struct _IplConvKernel IplConvKernel
#define IPL_DEPTH_16U
Definition: IplImage.h:60
#define IPL_DEPTH_1U
Definition: IplImage.h:58
#define IPL_DEPTH_MASK
Definition: IplImage.h:295
#define IPL_IMAGE_ALL_WITHOUT_MASK
Definition: IplImage.h:304
struct _IplTileInfo IplTileInfo
Definition: IplImage.h:115
struct _IplImage IplImage
#define IPL_ORIGIN_TL
Definition: IplImage.h:70
#define IPL_DEPTH_8U
Definition: IplImage.h:59
#define IPL_IMAGE_DATA
Definition: IplImage.h:298
#define IPL_IMAGE_HEADER
Definition: IplImage.h:297
#define IPL_DEPTH_8S
Definition: IplImage.h:63
#define IPL_DEPTH_32S
Definition: IplImage.h:65
#define IPL_DEPTH_32F
Definition: IplImage.h:61
#define YARP_IMAGE_ALIGN
Definition: IplImage.h:313
#define IPL_DEPTH_16S
Definition: IplImage.h:64
struct _IplConvKernelFP IplConvKernelFP
#define IPL_DATA_ORDER_PIXEL
Definition: IplImage.h:67
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