Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgcodecs/src/utils.cpp
16337 views
1
/*M///////////////////////////////////////////////////////////////////////////////////////
2
//
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
//
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
8
//
9
//
10
// Intel License Agreement
11
// For Open Source Computer Vision Library
12
//
13
// Copyright (C) 2000, Intel Corporation, all rights reserved.
14
// Third party copyrights are property of their respective owners.
15
//
16
// Redistribution and use in source and binary forms, with or without modification,
17
// are permitted provided that the following conditions are met:
18
//
19
// * Redistribution's of source code must retain the above copyright notice,
20
// this list of conditions and the following disclaimer.
21
//
22
// * Redistribution's in binary form must reproduce the above copyright notice,
23
// this list of conditions and the following disclaimer in the documentation
24
// and/or other materials provided with the distribution.
25
//
26
// * The name of Intel Corporation may not be used to endorse or promote products
27
// derived from this software without specific prior written permission.
28
//
29
// This software is provided by the copyright holders and contributors "as is" and
30
// any express or implied warranties, including, but not limited to, the implied
31
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32
// In no event shall the Intel Corporation or contributors be liable for any direct,
33
// indirect, incidental, special, exemplary, or consequential damages
34
// (including, but not limited to, procurement of substitute goods or services;
35
// loss of use, data, or profits; or business interruption) however caused
36
// and on any theory of liability, whether in contract, strict liability,
37
// or tort (including negligence or otherwise) arising in any way out of
38
// the use of this software, even if advised of the possibility of such damage.
39
//
40
//M*/
41
42
#include "precomp.hpp"
43
#include "utils.hpp"
44
45
int validateToInt(size_t sz)
46
{
47
int valueInt = (int)sz;
48
CV_Assert((size_t)valueInt == sz);
49
return valueInt;
50
}
51
52
#define SCALE 14
53
#define cR (int)(0.299*(1 << SCALE) + 0.5)
54
#define cG (int)(0.587*(1 << SCALE) + 0.5)
55
#define cB ((1 << SCALE) - cR - cG)
56
57
void icvCvt_BGR2Gray_8u_C3C1R( const uchar* rgb, int rgb_step,
58
uchar* gray, int gray_step,
59
CvSize size, int _swap_rb )
60
{
61
int i;
62
int swap_rb = _swap_rb ? 2 : 0;
63
for( ; size.height--; gray += gray_step )
64
{
65
for( i = 0; i < size.width; i++, rgb += 3 )
66
{
67
int t = descale( rgb[swap_rb]*cB + rgb[1]*cG + rgb[swap_rb^2]*cR, SCALE );
68
gray[i] = (uchar)t;
69
}
70
71
rgb += rgb_step - size.width*3;
72
}
73
}
74
75
76
void icvCvt_BGRA2Gray_16u_CnC1R( const ushort* rgb, int rgb_step,
77
ushort* gray, int gray_step,
78
CvSize size, int ncn, int _swap_rb )
79
{
80
int i;
81
int swap_rb = _swap_rb ? 2 : 0;
82
for( ; size.height--; gray += gray_step )
83
{
84
for( i = 0; i < size.width; i++, rgb += ncn )
85
{
86
int t = descale( rgb[swap_rb]*cB + rgb[1]*cG + rgb[swap_rb^2]*cR, SCALE );
87
gray[i] = (ushort)t;
88
}
89
90
rgb += rgb_step - size.width*ncn;
91
}
92
}
93
94
95
void icvCvt_BGRA2Gray_8u_C4C1R( const uchar* rgba, int rgba_step,
96
uchar* gray, int gray_step,
97
CvSize size, int _swap_rb )
98
{
99
int i;
100
int swap_rb = _swap_rb ? 2 : 0;
101
for( ; size.height--; gray += gray_step )
102
{
103
for( i = 0; i < size.width; i++, rgba += 4 )
104
{
105
int t = descale( rgba[swap_rb]*cB + rgba[1]*cG + rgba[swap_rb^2]*cR, SCALE );
106
gray[i] = (uchar)t;
107
}
108
109
rgba += rgba_step - size.width*4;
110
}
111
}
112
113
114
void icvCvt_Gray2BGR_8u_C1C3R( const uchar* gray, int gray_step,
115
uchar* bgr, int bgr_step, CvSize size )
116
{
117
int i;
118
for( ; size.height--; gray += gray_step )
119
{
120
for( i = 0; i < size.width; i++, bgr += 3 )
121
{
122
bgr[0] = bgr[1] = bgr[2] = gray[i];
123
}
124
bgr += bgr_step - size.width*3;
125
}
126
}
127
128
129
void icvCvt_Gray2BGR_16u_C1C3R( const ushort* gray, int gray_step,
130
ushort* bgr, int bgr_step, CvSize size )
131
{
132
int i;
133
for( ; size.height--; gray += gray_step/sizeof(gray[0]) )
134
{
135
for( i = 0; i < size.width; i++, bgr += 3 )
136
{
137
bgr[0] = bgr[1] = bgr[2] = gray[i];
138
}
139
bgr += bgr_step/sizeof(bgr[0]) - size.width*3;
140
}
141
}
142
143
144
void icvCvt_BGRA2BGR_8u_C4C3R( const uchar* bgra, int bgra_step,
145
uchar* bgr, int bgr_step,
146
CvSize size, int _swap_rb )
147
{
148
int i;
149
int swap_rb = _swap_rb ? 2 : 0;
150
for( ; size.height--; )
151
{
152
for( i = 0; i < size.width; i++, bgr += 3, bgra += 4 )
153
{
154
uchar t0 = bgra[swap_rb], t1 = bgra[1];
155
bgr[0] = t0; bgr[1] = t1;
156
t0 = bgra[swap_rb^2]; bgr[2] = t0;
157
}
158
bgr += bgr_step - size.width*3;
159
bgra += bgra_step - size.width*4;
160
}
161
}
162
163
164
void icvCvt_BGRA2BGR_16u_C4C3R( const ushort* bgra, int bgra_step,
165
ushort* bgr, int bgr_step,
166
CvSize size, int _swap_rb )
167
{
168
int i;
169
int swap_rb = _swap_rb ? 2 : 0;
170
for( ; size.height--; )
171
{
172
for( i = 0; i < size.width; i++, bgr += 3, bgra += 4 )
173
{
174
ushort t0 = bgra[swap_rb], t1 = bgra[1];
175
bgr[0] = t0; bgr[1] = t1;
176
t0 = bgra[swap_rb^2]; bgr[2] = t0;
177
}
178
bgr += bgr_step/sizeof(bgr[0]) - size.width*3;
179
bgra += bgra_step/sizeof(bgra[0]) - size.width*4;
180
}
181
}
182
183
184
void icvCvt_BGRA2RGBA_8u_C4R( const uchar* bgra, int bgra_step,
185
uchar* rgba, int rgba_step, CvSize size )
186
{
187
int i;
188
for( ; size.height--; )
189
{
190
for( i = 0; i < size.width; i++, bgra += 4, rgba += 4 )
191
{
192
uchar t0 = bgra[0], t1 = bgra[1];
193
uchar t2 = bgra[2], t3 = bgra[3];
194
rgba[0] = t2; rgba[1] = t1;
195
rgba[2] = t0; rgba[3] = t3;
196
}
197
bgra += bgra_step - size.width*4;
198
rgba += rgba_step - size.width*4;
199
}
200
}
201
202
void icvCvt_BGRA2RGBA_16u_C4R( const ushort* bgra, int bgra_step,
203
ushort* rgba, int rgba_step, CvSize size )
204
{
205
int i;
206
for( ; size.height--; )
207
{
208
for( i = 0; i < size.width; i++, bgra += 4, rgba += 4 )
209
{
210
ushort t0 = bgra[0], t1 = bgra[1];
211
ushort t2 = bgra[2], t3 = bgra[3];
212
213
rgba[0] = t2; rgba[1] = t1;
214
rgba[2] = t0; rgba[3] = t3;
215
}
216
bgra += bgra_step/sizeof(bgra[0]) - size.width*4;
217
rgba += rgba_step/sizeof(rgba[0]) - size.width*4;
218
}
219
}
220
221
222
void icvCvt_BGR2RGB_8u_C3R( const uchar* bgr, int bgr_step,
223
uchar* rgb, int rgb_step, CvSize size )
224
{
225
int i;
226
for( ; size.height--; )
227
{
228
for( i = 0; i < size.width; i++, bgr += 3, rgb += 3 )
229
{
230
uchar t0 = bgr[0], t1 = bgr[1], t2 = bgr[2];
231
rgb[2] = t0; rgb[1] = t1; rgb[0] = t2;
232
}
233
bgr += bgr_step - size.width*3;
234
rgb += rgb_step - size.width*3;
235
}
236
}
237
238
239
void icvCvt_BGR2RGB_16u_C3R( const ushort* bgr, int bgr_step,
240
ushort* rgb, int rgb_step, CvSize size )
241
{
242
int i;
243
for( ; size.height--; )
244
{
245
for( i = 0; i < size.width; i++, bgr += 3, rgb += 3 )
246
{
247
ushort t0 = bgr[0], t1 = bgr[1], t2 = bgr[2];
248
rgb[2] = t0; rgb[1] = t1; rgb[0] = t2;
249
}
250
bgr += bgr_step - size.width*3;
251
rgb += rgb_step - size.width*3;
252
}
253
}
254
255
256
typedef unsigned short ushort;
257
258
void icvCvt_BGR5552Gray_8u_C2C1R( const uchar* bgr555, int bgr555_step,
259
uchar* gray, int gray_step, CvSize size )
260
{
261
int i;
262
for( ; size.height--; gray += gray_step, bgr555 += bgr555_step )
263
{
264
for( i = 0; i < size.width; i++ )
265
{
266
int t = descale( ((((ushort*)bgr555)[i] << 3) & 0xf8)*cB +
267
((((ushort*)bgr555)[i] >> 2) & 0xf8)*cG +
268
((((ushort*)bgr555)[i] >> 7) & 0xf8)*cR, SCALE );
269
gray[i] = (uchar)t;
270
}
271
}
272
}
273
274
275
void icvCvt_BGR5652Gray_8u_C2C1R( const uchar* bgr565, int bgr565_step,
276
uchar* gray, int gray_step, CvSize size )
277
{
278
int i;
279
for( ; size.height--; gray += gray_step, bgr565 += bgr565_step )
280
{
281
for( i = 0; i < size.width; i++ )
282
{
283
int t = descale( ((((ushort*)bgr565)[i] << 3) & 0xf8)*cB +
284
((((ushort*)bgr565)[i] >> 3) & 0xfc)*cG +
285
((((ushort*)bgr565)[i] >> 8) & 0xf8)*cR, SCALE );
286
gray[i] = (uchar)t;
287
}
288
}
289
}
290
291
292
void icvCvt_BGR5552BGR_8u_C2C3R( const uchar* bgr555, int bgr555_step,
293
uchar* bgr, int bgr_step, CvSize size )
294
{
295
int i;
296
for( ; size.height--; bgr555 += bgr555_step )
297
{
298
for( i = 0; i < size.width; i++, bgr += 3 )
299
{
300
int t0 = (((ushort*)bgr555)[i] << 3) & 0xf8;
301
int t1 = (((ushort*)bgr555)[i] >> 2) & 0xf8;
302
int t2 = (((ushort*)bgr555)[i] >> 7) & 0xf8;
303
bgr[0] = (uchar)t0; bgr[1] = (uchar)t1; bgr[2] = (uchar)t2;
304
}
305
bgr += bgr_step - size.width*3;
306
}
307
}
308
309
310
void icvCvt_BGR5652BGR_8u_C2C3R( const uchar* bgr565, int bgr565_step,
311
uchar* bgr, int bgr_step, CvSize size )
312
{
313
int i;
314
for( ; size.height--; bgr565 += bgr565_step )
315
{
316
for( i = 0; i < size.width; i++, bgr += 3 )
317
{
318
int t0 = (((ushort*)bgr565)[i] << 3) & 0xf8;
319
int t1 = (((ushort*)bgr565)[i] >> 3) & 0xfc;
320
int t2 = (((ushort*)bgr565)[i] >> 8) & 0xf8;
321
bgr[0] = (uchar)t0; bgr[1] = (uchar)t1; bgr[2] = (uchar)t2;
322
}
323
bgr += bgr_step - size.width*3;
324
}
325
}
326
327
328
void icvCvt_CMYK2BGR_8u_C4C3R( const uchar* cmyk, int cmyk_step,
329
uchar* bgr, int bgr_step, CvSize size )
330
{
331
int i;
332
for( ; size.height--; )
333
{
334
for( i = 0; i < size.width; i++, bgr += 3, cmyk += 4 )
335
{
336
int c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
337
c = k - ((255 - c)*k>>8);
338
m = k - ((255 - m)*k>>8);
339
y = k - ((255 - y)*k>>8);
340
bgr[2] = (uchar)c; bgr[1] = (uchar)m; bgr[0] = (uchar)y;
341
}
342
bgr += bgr_step - size.width*3;
343
cmyk += cmyk_step - size.width*4;
344
}
345
}
346
347
348
void icvCvt_CMYK2Gray_8u_C4C1R( const uchar* cmyk, int cmyk_step,
349
uchar* gray, int gray_step, CvSize size )
350
{
351
int i;
352
for( ; size.height--; )
353
{
354
for( i = 0; i < size.width; i++, cmyk += 4 )
355
{
356
int c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
357
c = k - ((255 - c)*k>>8);
358
m = k - ((255 - m)*k>>8);
359
y = k - ((255 - y)*k>>8);
360
int t = descale( y*cB + m*cG + c*cR, SCALE );
361
gray[i] = (uchar)t;
362
}
363
gray += gray_step;
364
cmyk += cmyk_step - size.width*4;
365
}
366
}
367
368
369
void CvtPaletteToGray( const PaletteEntry* palette, uchar* grayPalette, int entries )
370
{
371
int i;
372
for( i = 0; i < entries; i++ )
373
{
374
icvCvt_BGR2Gray_8u_C3C1R( (uchar*)(palette + i), 0, grayPalette + i, 0, cvSize(1,1) );
375
}
376
}
377
378
379
void FillGrayPalette( PaletteEntry* palette, int bpp, bool negative )
380
{
381
int i, length = 1 << bpp;
382
int xor_mask = negative ? 255 : 0;
383
384
for( i = 0; i < length; i++ )
385
{
386
int val = (i * 255/(length - 1)) ^ xor_mask;
387
palette[i].b = palette[i].g = palette[i].r = (uchar)val;
388
palette[i].a = 0;
389
}
390
}
391
392
393
bool IsColorPalette( PaletteEntry* palette, int bpp )
394
{
395
int i, length = 1 << bpp;
396
397
for( i = 0; i < length; i++ )
398
{
399
if( palette[i].b != palette[i].g ||
400
palette[i].b != palette[i].r )
401
return true;
402
}
403
404
return false;
405
}
406
407
408
uchar* FillUniColor( uchar* data, uchar*& line_end,
409
int step, int width3,
410
int& y, int height,
411
int count3, PaletteEntry clr )
412
{
413
do
414
{
415
uchar* end = data + count3;
416
417
if( end > line_end )
418
end = line_end;
419
420
count3 -= (int)(end - data);
421
422
for( ; data < end; data += 3 )
423
{
424
WRITE_PIX( data, clr );
425
}
426
427
if( data >= line_end )
428
{
429
line_end += step;
430
data = line_end - width3;
431
if( ++y >= height ) break;
432
}
433
}
434
while( count3 > 0 );
435
436
return data;
437
}
438
439
440
uchar* FillUniGray( uchar* data, uchar*& line_end,
441
int step, int width,
442
int& y, int height,
443
int count, uchar clr )
444
{
445
do
446
{
447
uchar* end = data + count;
448
449
if( end > line_end )
450
end = line_end;
451
452
count -= (int)(end - data);
453
454
for( ; data < end; data++ )
455
{
456
*data = clr;
457
}
458
459
if( data >= line_end )
460
{
461
line_end += step;
462
data = line_end - width;
463
if( ++y >= height ) break;
464
}
465
}
466
while( count > 0 );
467
468
return data;
469
}
470
471
472
uchar* FillColorRow8( uchar* data, uchar* indices, int len, PaletteEntry* palette )
473
{
474
uchar* end = data + len*3;
475
while( (data += 3) < end )
476
{
477
*((PaletteEntry*)(data-3)) = palette[*indices++];
478
}
479
PaletteEntry clr = palette[indices[0]];
480
WRITE_PIX( data - 3, clr );
481
return data;
482
}
483
484
485
uchar* FillGrayRow8( uchar* data, uchar* indices, int len, uchar* palette )
486
{
487
int i;
488
for( i = 0; i < len; i++ )
489
{
490
data[i] = palette[indices[i]];
491
}
492
return data + len;
493
}
494
495
496
uchar* FillColorRow4( uchar* data, uchar* indices, int len, PaletteEntry* palette )
497
{
498
uchar* end = data + len*3;
499
500
while( (data += 6) < end )
501
{
502
int idx = *indices++;
503
*((PaletteEntry*)(data-6)) = palette[idx >> 4];
504
*((PaletteEntry*)(data-3)) = palette[idx & 15];
505
}
506
507
int idx = indices[0];
508
PaletteEntry clr = palette[idx >> 4];
509
WRITE_PIX( data - 6, clr );
510
511
if( data == end )
512
{
513
clr = palette[idx & 15];
514
WRITE_PIX( data - 3, clr );
515
}
516
return end;
517
}
518
519
520
uchar* FillGrayRow4( uchar* data, uchar* indices, int len, uchar* palette )
521
{
522
uchar* end = data + len;
523
while( (data += 2) < end )
524
{
525
int idx = *indices++;
526
data[-2] = palette[idx >> 4];
527
data[-1] = palette[idx & 15];
528
}
529
530
int idx = indices[0];
531
uchar clr = palette[idx >> 4];
532
data[-2] = clr;
533
534
if( data == end )
535
{
536
clr = palette[idx & 15];
537
data[-1] = clr;
538
}
539
return end;
540
}
541
542
543
uchar* FillColorRow1( uchar* data, uchar* indices, int len, PaletteEntry* palette )
544
{
545
uchar* end = data + len*3;
546
547
const PaletteEntry p0 = palette[0], p1 = palette[1];
548
549
while( (data += 24) < end )
550
{
551
int idx = *indices++;
552
*((PaletteEntry*)(data - 24)) = (idx & 128) ? p1 : p0;
553
*((PaletteEntry*)(data - 21)) = (idx & 64) ? p1 : p0;
554
*((PaletteEntry*)(data - 18)) = (idx & 32) ? p1 : p0;
555
*((PaletteEntry*)(data - 15)) = (idx & 16) ? p1 : p0;
556
*((PaletteEntry*)(data - 12)) = (idx & 8) ? p1 : p0;
557
*((PaletteEntry*)(data - 9)) = (idx & 4) ? p1 : p0;
558
*((PaletteEntry*)(data - 6)) = (idx & 2) ? p1 : p0;
559
*((PaletteEntry*)(data - 3)) = (idx & 1) ? p1 : p0;
560
}
561
562
int idx = indices[0];
563
for( data -= 24; data < end; data += 3, idx += idx )
564
{
565
const PaletteEntry clr = (idx & 128) ? p1 : p0;
566
WRITE_PIX( data, clr );
567
}
568
569
return data;
570
}
571
572
573
uchar* FillGrayRow1( uchar* data, uchar* indices, int len, uchar* palette )
574
{
575
uchar* end = data + len;
576
577
const uchar p0 = palette[0], p1 = palette[1];
578
579
while( (data += 8) < end )
580
{
581
int idx = *indices++;
582
*((uchar*)(data - 8)) = (idx & 128) ? p1 : p0;
583
*((uchar*)(data - 7)) = (idx & 64) ? p1 : p0;
584
*((uchar*)(data - 6)) = (idx & 32) ? p1 : p0;
585
*((uchar*)(data - 5)) = (idx & 16) ? p1 : p0;
586
*((uchar*)(data - 4)) = (idx & 8) ? p1 : p0;
587
*((uchar*)(data - 3)) = (idx & 4) ? p1 : p0;
588
*((uchar*)(data - 2)) = (idx & 2) ? p1 : p0;
589
*((uchar*)(data - 1)) = (idx & 1) ? p1 : p0;
590
}
591
592
int idx = indices[0];
593
for( data -= 8; data < end; data++, idx += idx )
594
{
595
data[0] = (idx & 128) ? p1 : p0;
596
}
597
598
return data;
599
}
600
601
602
CV_IMPL void
603
cvConvertImage( const CvArr* srcarr, CvArr* dstarr, int flags )
604
{
605
CvMat* temp = 0;
606
607
CV_FUNCNAME( "cvConvertImage" );
608
609
__BEGIN__;
610
611
CvMat srcstub, *src;
612
CvMat dststub, *dst;
613
int src_cn, dst_cn, swap_rb = flags & CV_CVTIMG_SWAP_RB;
614
615
CV_CALL( src = cvGetMat( srcarr, &srcstub ));
616
CV_CALL( dst = cvGetMat( dstarr, &dststub ));
617
618
src_cn = CV_MAT_CN( src->type );
619
dst_cn = CV_MAT_CN( dst->type );
620
621
if( src_cn != 1 && src_cn != 3 && src_cn != 4 )
622
CV_ERROR( CV_BadNumChannels, "Source image must have 1, 3 or 4 channels" );
623
624
if( CV_MAT_DEPTH( dst->type ) != CV_8U )
625
CV_ERROR( CV_BadDepth, "Destination image must be 8u" );
626
627
if( CV_MAT_CN(dst->type) != 1 && CV_MAT_CN(dst->type) != 3 )
628
CV_ERROR( CV_BadNumChannels, "Destination image must have 1 or 3 channels" );
629
630
if( !CV_ARE_DEPTHS_EQ( src, dst ))
631
{
632
int src_depth = CV_MAT_DEPTH(src->type);
633
double scale = src_depth <= CV_8S ? 1 : src_depth <= CV_32S ? 1./256 : 255;
634
double shift = src_depth == CV_8S || src_depth == CV_16S ? 128 : 0;
635
636
if( !CV_ARE_CNS_EQ( src, dst ))
637
{
638
temp = cvCreateMat( src->height, src->width,
639
(src->type & CV_MAT_CN_MASK)|(dst->type & CV_MAT_DEPTH_MASK));
640
cvConvertScale( src, temp, scale, shift );
641
src = temp;
642
}
643
else
644
{
645
cvConvertScale( src, dst, scale, shift );
646
src = dst;
647
}
648
}
649
650
if( src_cn != dst_cn || (src_cn == 3 && swap_rb) )
651
{
652
uchar *s = src->data.ptr, *d = dst->data.ptr;
653
int s_step = src->step, d_step = dst->step;
654
int code = src_cn*10 + dst_cn;
655
CvSize size = {src->cols, src->rows};
656
657
if( CV_IS_MAT_CONT(src->type & dst->type) )
658
{
659
size.width *= size.height;
660
size.height = 1;
661
s_step = d_step = /*CV_STUB_STEP*/ (1 << 30);
662
}
663
664
switch( code )
665
{
666
case 13:
667
icvCvt_Gray2BGR_8u_C1C3R( s, s_step, d, d_step, size );
668
break;
669
case 31:
670
icvCvt_BGR2Gray_8u_C3C1R( s, s_step, d, d_step, size, swap_rb );
671
break;
672
case 33:
673
CV_Assert(swap_rb);
674
icvCvt_RGB2BGR_8u_C3R( s, s_step, d, d_step, size );
675
break;
676
case 41:
677
icvCvt_BGRA2Gray_8u_C4C1R( s, s_step, d, d_step, size, swap_rb );
678
break;
679
case 43:
680
icvCvt_BGRA2BGR_8u_C4C3R( s, s_step, d, d_step, size, swap_rb );
681
break;
682
default:
683
CV_ERROR( CV_StsUnsupportedFormat, "Unsupported combination of input/output formats" );
684
}
685
src = dst;
686
}
687
688
if( flags & CV_CVTIMG_FLIP )
689
{
690
CV_CALL( cvFlip( src, dst, 0 ));
691
}
692
else if( src != dst )
693
{
694
CV_CALL( cvCopy( src, dst ));
695
}
696
697
__END__;
698
699
cvReleaseMat( &temp );
700
}
701
702