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