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