1 | /* ----------------- */ |
---|
2 | /* --- nrmem2X.c --- */ |
---|
3 | /* ----------------- */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * 2002/06/11 ajout des fonctions endline |
---|
13 | */ |
---|
14 | #include <stdio.h> |
---|
15 | #include <stddef.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <math.h> // fabs |
---|
18 | |
---|
19 | #include "mypredef.h" |
---|
20 | #include "nrtype.h" |
---|
21 | #include "nrdef.h" |
---|
22 | #include "nrmacro.h" |
---|
23 | #include "nrkernel.h" |
---|
24 | |
---|
25 | #include "nrtypex.h" |
---|
26 | |
---|
27 | #include "nrmem1.h" |
---|
28 | #include "nrmem2.h" |
---|
29 | #include "nrmem2x.h" |
---|
30 | |
---|
31 | /* ------------------------------------------ */ |
---|
32 | /* --- ATTENTION ---------------------------- */ |
---|
33 | /* ------------------------------------------ */ |
---|
34 | /* l'utilisation des fonctions endline */ |
---|
35 | /* necessite l'allocation d'une ligne de plus */ |
---|
36 | /* (a cause du m[i+1] */ |
---|
37 | /* ------------------------------------------ */ |
---|
38 | /* ------------------------------------------------------------------------------------ */ |
---|
39 | IMAGE_EXPORT(void) reset_endline_bmatrix(byte **m, long nrl, long nrh, long ncl, long nch) |
---|
40 | /* ------------------------------------------------------------------------------------ */ |
---|
41 | { |
---|
42 | long i, ncol=nch-ncl+1; |
---|
43 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
44 | return; |
---|
45 | } |
---|
46 | /* --------------------------------------------------------------------------------------- */ |
---|
47 | IMAGE_EXPORT(void) reset_endline_i16matrix(int16 **m, long nrl, long nrh, long ncl, long nch) |
---|
48 | /* --------------------------------------------------------------------------------------- */ |
---|
49 | { |
---|
50 | long i, ncol=nch-ncl+1; |
---|
51 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
52 | return; |
---|
53 | } |
---|
54 | /* ----------------------------------------------------------------------------------------- */ |
---|
55 | IMAGE_EXPORT(void) reset_endline_ui16matrix(uint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
56 | /* ----------------------------------------------------------------------------------------- */ |
---|
57 | { |
---|
58 | long i, ncol=nch-ncl+1; |
---|
59 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
60 | return; |
---|
61 | } |
---|
62 | /* ----------------------------------------------------------------------------------- */ |
---|
63 | IMAGE_EXPORT(void) reset_endline_imatrix(int **m, long nrl, long nrh, long ncl, long nch) |
---|
64 | /* ----------------------------------------------------------------------------------- */ |
---|
65 | { |
---|
66 | long i, ncol=nch-ncl+1; |
---|
67 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
68 | return; |
---|
69 | } |
---|
70 | /* --------------------------------------------------------------------------------------- */ |
---|
71 | IMAGE_EXPORT(void) reset_endline_i32matrix(int32 **m, long nrl, long nrh, long ncl, long nch) |
---|
72 | /* --------------------------------------------------------------------------------------- */ |
---|
73 | { |
---|
74 | long i, ncol=nch-ncl+1; |
---|
75 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
76 | return; |
---|
77 | } |
---|
78 | /* ----------------------------------------------------------------------------------------- */ |
---|
79 | IMAGE_EXPORT(void) reset_endline_ui32matrix(uint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
80 | /* ----------------------------------------------------------------------------------------- */ |
---|
81 | { |
---|
82 | long i, ncol=nch-ncl+1; |
---|
83 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
84 | return; |
---|
85 | } |
---|
86 | /* --------------------------------------------------------------------------------------- */ |
---|
87 | IMAGE_EXPORT(void) reset_endline_i64matrix(int64 **m, long nrl, long nrh, long ncl, long nch) |
---|
88 | /* --------------------------------------------------------------------------------------- */ |
---|
89 | { |
---|
90 | long i, ncol=nch-ncl+1; |
---|
91 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
92 | return; |
---|
93 | } |
---|
94 | |
---|
95 | /* ------------------------------------------------------ */ |
---|
96 | IMAGE_EXPORT(void) endline_bmatrix(byte **m, long i, long l) |
---|
97 | /* ------------------------------------------------------ */ |
---|
98 | { |
---|
99 | m[i+1] = m[i] + l; |
---|
100 | } |
---|
101 | /* --------------------------------------------------------- */ |
---|
102 | IMAGE_EXPORT(void) endline_i16matrix(int16 **m, long i, long l) |
---|
103 | /* --------------------------------------------------------- */ |
---|
104 | { |
---|
105 | m[i+1] = m[i] + l; |
---|
106 | } |
---|
107 | /* ----------------------------------------------------------- */ |
---|
108 | IMAGE_EXPORT(void) endline_ui16matrix(uint16 **m, long i, long l) |
---|
109 | /* ----------------------------------------------------------- */ |
---|
110 | { |
---|
111 | m[i+1] = m[i] + l; |
---|
112 | } |
---|
113 | /* ----------------------------------------------------- */ |
---|
114 | IMAGE_EXPORT(void) endline_imatrix(int **m, long i, long l) |
---|
115 | /* ----------------------------------------------------- */ |
---|
116 | { |
---|
117 | m[i+1] = m[i] + l; |
---|
118 | } |
---|
119 | /* --------------------------------------------------------- */ |
---|
120 | IMAGE_EXPORT(void) endline_i32matrix(int32 **m, long i, long l) |
---|
121 | /* --------------------------------------------------------- */ |
---|
122 | { |
---|
123 | m[i+1] = m[i] + l; |
---|
124 | } |
---|
125 | /* ----------------------------------------------------------- */ |
---|
126 | IMAGE_EXPORT(void) endline_ui32matrix(uint32 **m, long i, long l) |
---|
127 | /* ----------------------------------------------------------- */ |
---|
128 | { |
---|
129 | m[i+1] = m[i] + l; |
---|
130 | } |
---|
131 | /* --------------------------------------------------------- */ |
---|
132 | IMAGE_EXPORT(void) endline_i64matrix(int64 **m, long i, long l) |
---|
133 | /* --------------------------------------------------------- */ |
---|
134 | { |
---|
135 | m[i+1] = m[i] + l; |
---|
136 | } |
---|
137 | /* ----------------------------------------------------------------- */ |
---|
138 | IMAGE_EXPORT(void) endline0_bmatrix(byte **m, long i, long l, long ncl) |
---|
139 | /* ----------------------------------------------------------------- */ |
---|
140 | { |
---|
141 | m[i+1] = m[i] + l + 1; |
---|
142 | |
---|
143 | m[i][ncl] = (byte) l; |
---|
144 | } |
---|
145 | /* -------------------------------------------------------------------- */ |
---|
146 | IMAGE_EXPORT(void) endline0_i16matrix(int16 **m, long i, long l, long ncl) |
---|
147 | /* -------------------------------------------------------------------- */ |
---|
148 | { |
---|
149 | m[i+1] = m[i] + l + 1; |
---|
150 | |
---|
151 | m[i][ncl] = (int16) l; |
---|
152 | } |
---|
153 | /* ---------------------------------------------------------------------- */ |
---|
154 | IMAGE_EXPORT(void) endline0_ui16matrix(uint16 **m, long i, long l, long ncl) |
---|
155 | /* ---------------------------------------------------------------------- */ |
---|
156 | { |
---|
157 | m[i+1] = m[i] + l + 1; |
---|
158 | |
---|
159 | m[i][ncl] = (uint16) l; |
---|
160 | } |
---|
161 | /* ---------------------------------------------------------------- */ |
---|
162 | IMAGE_EXPORT(void) endline0_imatrix(int **m, long i, long l, long ncl) |
---|
163 | /* ---------------------------------------------------------------- */ |
---|
164 | { |
---|
165 | m[i+1] = m[i] + l + 1; |
---|
166 | |
---|
167 | m[i][ncl] = (int) l; |
---|
168 | } |
---|
169 | /* -------------------------------------------------------------------- */ |
---|
170 | IMAGE_EXPORT(void) endline0_i32matrix(int32 **m, long i, long l, long ncl) |
---|
171 | /* -------------------------------------------------------------------- */ |
---|
172 | { |
---|
173 | m[i+1] = m[i] + l + 1; |
---|
174 | |
---|
175 | m[i][ncl] = (int32) l; |
---|
176 | } |
---|
177 | /* ---------------------------------------------------------------------- */ |
---|
178 | IMAGE_EXPORT(void) endline0_ui32matrix(uint32 **m, long i, long l, long ncl) |
---|
179 | /* ---------------------------------------------------------------------- */ |
---|
180 | { |
---|
181 | m[i+1] = m[i] + l + 1; |
---|
182 | |
---|
183 | m[i][ncl] = (uint32) l; |
---|
184 | } |
---|
185 | /* -------------------------------------------------------------------- */ |
---|
186 | IMAGE_EXPORT(void) endline0_i64matrix(int64 **m, long i, long l, long ncl) |
---|
187 | /* -------------------------------------------------------------------- */ |
---|
188 | { |
---|
189 | m[i+1] = m[i] + l + 1; |
---|
190 | |
---|
191 | m[i][ncl] = (int64) l; |
---|
192 | } |
---|
193 | /* ----------------------------------------------------------------- */ |
---|
194 | IMAGE_EXPORT(void) endline1_bmatrix(byte **m, long i, long l, long ncl) |
---|
195 | /* ----------------------------------------------------------------- */ |
---|
196 | { |
---|
197 | m[i+1] = m[i] + l + 1; |
---|
198 | |
---|
199 | m[i][ncl-1] = (byte) l; |
---|
200 | } |
---|
201 | /* -------------------------------------------------------------------- */ |
---|
202 | IMAGE_EXPORT(void) endline1_i16matrix(int16 **m, long i, long l, long ncl) |
---|
203 | /* -------------------------------------------------------------------- */ |
---|
204 | { |
---|
205 | m[i+1] = m[i] + l + 1; |
---|
206 | |
---|
207 | m[i][ncl-1] = (int16) l; |
---|
208 | } |
---|
209 | /* ---------------------------------------------------------------------- */ |
---|
210 | IMAGE_EXPORT(void) endline1_ui16matrix(uint16 **m, long i, long l, long ncl) |
---|
211 | /* ---------------------------------------------------------------------- */ |
---|
212 | { |
---|
213 | m[i+1] = m[i] + l + 1; |
---|
214 | |
---|
215 | m[i][ncl-1] = (uint16) l; |
---|
216 | } |
---|
217 | /* ---------------------------------------------------------------- */ |
---|
218 | IMAGE_EXPORT(void) endline1_imatrix(int **m, long i, long l, long ncl) |
---|
219 | /* ---------------------------------------------------------------- */ |
---|
220 | { |
---|
221 | m[i+1] = m[i] + l + 1; |
---|
222 | |
---|
223 | m[i][ncl-1] = (int) l; |
---|
224 | } |
---|
225 | /* -------------------------------------------------------------------- */ |
---|
226 | IMAGE_EXPORT(void) endline1_i32matrix(int32 **m, long i, long l, long ncl) |
---|
227 | /* -------------------------------------------------------------------- */ |
---|
228 | { |
---|
229 | m[i+1] = m[i] + l + 1; |
---|
230 | |
---|
231 | m[i][ncl-1] = (int32) l; |
---|
232 | } |
---|
233 | /* ---------------------------------------------------------------------- */ |
---|
234 | IMAGE_EXPORT(void) endline1_ui32matrix(uint32 **m, long i, long l, long ncl) |
---|
235 | /* ---------------------------------------------------------------------- */ |
---|
236 | { |
---|
237 | m[i+1] = m[i] + l + 1; |
---|
238 | |
---|
239 | m[i][ncl-1] = (uint32) l; |
---|
240 | } |
---|
241 | /* -------------------------------------------------------------------- */ |
---|
242 | IMAGE_EXPORT(void) endline1_i64matrix(int64 **m, long i, long l, long ncl) |
---|
243 | /* -------------------------------------------------------------------- */ |
---|
244 | { |
---|
245 | m[i+1] = m[i] + l + 1; |
---|
246 | |
---|
247 | m[i][ncl-1] = (int64) l; |
---|
248 | } |
---|
249 | |
---|
250 | /* -------------------------------------------------------------------------------------- */ |
---|
251 | IMAGE_EXPORT(void) resize_si16Pmatrix(si16Point **m, long nrl, long nrh, long ncl, long nch) |
---|
252 | /* -------------------------------------------------------------------------------------- */ |
---|
253 | { |
---|
254 | long i, ncol=nch-ncl+1; |
---|
255 | |
---|
256 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
257 | } |
---|
258 | /* -------------------------------------------------------------------------------------- */ |
---|
259 | IMAGE_EXPORT(void) resize_ui16Pmatrix(ui16Point **m, long nrl, long nrh, long ncl, long nch) |
---|
260 | /* -------------------------------------------------------------------------------------- */ |
---|
261 | { |
---|
262 | long i, ncol=nch-ncl+1; |
---|
263 | |
---|
264 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
265 | } |
---|
266 | /* -------------------------------------------------------------------------------------- */ |
---|
267 | IMAGE_EXPORT(void) resize_si32Pmatrix(si32Point **m, long nrl, long nrh, long ncl, long nch) |
---|
268 | /* -------------------------------------------------------------------------------------- */ |
---|
269 | { |
---|
270 | long i, ncol=nch-ncl+1; |
---|
271 | |
---|
272 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
273 | } |
---|
274 | /* -------------------------------------------------------------------------------------- */ |
---|
275 | IMAGE_EXPORT(void) resize_ui32Pmatrix(ui32Point **m, long nrl, long nrh, long ncl, long nch) |
---|
276 | /* -------------------------------------------------------------------------------------- */ |
---|
277 | { |
---|
278 | long i, ncol=nch-ncl+1; |
---|
279 | |
---|
280 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
281 | } |
---|
282 | /* ------------------------------------------------------------------------------------ */ |
---|
283 | IMAGE_EXPORT(void) resize_f32Pmatrix(f32Point **m, long nrl, long nrh, long ncl, long nch) |
---|
284 | /* ------------------------------------------------------------------------------------ */ |
---|
285 | { |
---|
286 | long i, ncol=nch-ncl+1; |
---|
287 | |
---|
288 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
289 | } |
---|
290 | // Triplet Matrix |
---|
291 | /* ---------------------------------------------------------------------------------------- */ |
---|
292 | IMAGE_EXPORT(void) resize_si16Tmatrix(si16Triplet **m, long nrl, long nrh, long ncl, long nch) |
---|
293 | /* ---------------------------------------------------------------------------------------- */ |
---|
294 | { |
---|
295 | long i, ncol=nch-ncl+1; |
---|
296 | |
---|
297 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
298 | } |
---|
299 | /* ---------------------------------------------------------------------------------------- */ |
---|
300 | IMAGE_EXPORT(void) resize_ui16Tmatrix(ui16Triplet **m, long nrl, long nrh, long ncl, long nch) |
---|
301 | /* ---------------------------------------------------------------------------------------- */ |
---|
302 | { |
---|
303 | long i, ncol=nch-ncl+1; |
---|
304 | |
---|
305 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
306 | } |
---|
307 | /* ---------------------------------------------------------------------------------------- */ |
---|
308 | IMAGE_EXPORT(void) resize_si32Tmatrix(si32Triplet **m, long nrl, long nrh, long ncl, long nch) |
---|
309 | /* ---------------------------------------------------------------------------------------- */ |
---|
310 | { |
---|
311 | long i, ncol=nch-ncl+1; |
---|
312 | |
---|
313 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
314 | } |
---|
315 | /* ---------------------------------------------------------------------------------------- */ |
---|
316 | IMAGE_EXPORT(void) resize_ui32Tmatrix(ui32Triplet **m, long nrl, long nrh, long ncl, long nch) |
---|
317 | /* ---------------------------------------------------------------------------------------- */ |
---|
318 | { |
---|
319 | long i, ncol=nch-ncl+1; |
---|
320 | |
---|
321 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
322 | } |
---|
323 | /* -------------------------------------------------------------------------------------- */ |
---|
324 | IMAGE_EXPORT(void) resize_f32Tmatrix(f32Triplet **m, long nrl, long nrh, long ncl, long nch) |
---|
325 | /* -------------------------------------------------------------------------------------- */ |
---|
326 | { |
---|
327 | long i, ncol=nch-ncl+1; |
---|
328 | |
---|
329 | for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol; |
---|
330 | } |
---|
331 | /* |
---|
332 | * -------------- |
---|
333 | * matrix_reverse |
---|
334 | * -------------- |
---|
335 | */ |
---|
336 | /* ---------------------------------------------------------------- */ |
---|
337 | IMAGE_EXPORT(void) bmatrix_reverse(byte **m, long nrl, long nrh, long ncl, long nch) |
---|
338 | /* ---------------------------------------------------------------- */ |
---|
339 | { |
---|
340 | long i, mrow=(nrl+nrh+1)/2; |
---|
341 | byte *t; |
---|
342 | |
---|
343 | for(i=nrl; i<mrow; i++) { |
---|
344 | t = m[i]; |
---|
345 | m[i] = m[nrh-i]; |
---|
346 | m[nrh-i] = t; |
---|
347 | } |
---|
348 | } |
---|
349 | /* ----------------------------------------------------------------- */ |
---|
350 | IMAGE_EXPORT(void) smatrix_reverse(sint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
351 | /* ----------------------------------------------------------------- */ |
---|
352 | { |
---|
353 | long i, mrow=(nrl+nrh+1)/2; |
---|
354 | sint16 *t; |
---|
355 | |
---|
356 | for(i=nrl; i<mrow; i++) { |
---|
357 | t = m[i]; |
---|
358 | m[i] = m[nrh-i]; |
---|
359 | m[nrh-i] = t; |
---|
360 | } |
---|
361 | } |
---|
362 | /* ------------------------------------------------------------------- */ |
---|
363 | IMAGE_EXPORT(void) usmatrix_reverse(uint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
364 | /* ------------------------------------------------------------------- */ |
---|
365 | { |
---|
366 | long i, mrow=(nrl+nrh+1)/2; |
---|
367 | uint16 *t; |
---|
368 | |
---|
369 | for(i=nrl; i<mrow; i++) { |
---|
370 | t = m[i]; |
---|
371 | m[i] = m[nrh-i]; |
---|
372 | m[nrh-i] = t; |
---|
373 | } |
---|
374 | } |
---|
375 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
376 | IMAGE_EXPORT(void) desinterlace_bmatrix(byte **S, long nrl, long nrh, long ncl, long nch, byte **D0, byte **D1) |
---|
377 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
378 | { |
---|
379 | int i, i0, i1; |
---|
380 | int j; |
---|
381 | |
---|
382 | i0 = i1 = nrl; |
---|
383 | |
---|
384 | if((nrl&1)==0) { |
---|
385 | |
---|
386 | // nrl is even |
---|
387 | for(i=nrl; i<=nrh; i+=2) { |
---|
388 | //dup_bvector(S[i+0], ncl, nch, D0[i0++]); |
---|
389 | //dup_bvector(S[i+1], ncl, nch, D1[i1++]); |
---|
390 | for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; |
---|
391 | for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; |
---|
392 | } |
---|
393 | // epilog |
---|
394 | if((nrh&1)==0) { |
---|
395 | //dup_bvector(S[nrh], ncl, nch, D0[i0]); |
---|
396 | for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; |
---|
397 | } |
---|
398 | |
---|
399 | } else { |
---|
400 | |
---|
401 | // nrl is odd |
---|
402 | for(i=nrl; i<=nrh; i+=2) { |
---|
403 | //dup_bvector(S[i+0], ncl, nch, D1[i1++]); |
---|
404 | //dup_bvector(S[i+1], ncl, nch, D0[i0++]); |
---|
405 | for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; |
---|
406 | for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; |
---|
407 | } |
---|
408 | // epilog |
---|
409 | if((nrh&1)==1) { |
---|
410 | //dup_bvector(S[nrh], ncl, nch, D1[i1]); |
---|
411 | for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; |
---|
412 | } |
---|
413 | } |
---|
414 | } |
---|
415 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
416 | IMAGE_EXPORT(void) desinterlace_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb8 **D0, rgb8 **D1) |
---|
417 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
418 | { |
---|
419 | int i, i0, i1; |
---|
420 | int j; |
---|
421 | |
---|
422 | i0 = i1 = nrl; |
---|
423 | |
---|
424 | if((nrl&1)==0) { |
---|
425 | |
---|
426 | // nrl is even |
---|
427 | for(i=nrl; i<=nrh; i+=2) { |
---|
428 | //dup_rgb8vector(S[i+0], ncl, nch, D0[i0++]); |
---|
429 | //dup_rgb8vector(S[i+1], ncl, nch, D1[i1++]); |
---|
430 | for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; |
---|
431 | for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; |
---|
432 | } |
---|
433 | // epilog |
---|
434 | if((nrh&1)==0) { |
---|
435 | //dup_rgb8vector(S[nrh], ncl, nch, D0[i0]); |
---|
436 | for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; |
---|
437 | } |
---|
438 | |
---|
439 | } else { |
---|
440 | |
---|
441 | // nrl is odd |
---|
442 | for(i=nrl; i<=nrh; i+=2) { |
---|
443 | //dup_rgb8vector(S[i+0], ncl, nch, D1[i1++]); |
---|
444 | //dup_rgb8vector(S[i+1], ncl, nch, D0[i0++]); |
---|
445 | for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; |
---|
446 | for(j=ncl; j<=nch; j++) D0[i0][j] = S[i][j]; i0++; |
---|
447 | } |
---|
448 | // epilog |
---|
449 | if((nrh&1)==1) { |
---|
450 | //dup_rgb8vector(S[nrh], ncl, nch, D1[i1]); |
---|
451 | for(j=ncl; j<=nch; j++) D1[i1][j] = S[i][j]; i1++; |
---|
452 | } |
---|
453 | } |
---|
454 | } |
---|
455 | /* ------------------------------------------------------------------------------------------------------- */ |
---|
456 | IMAGE_EXPORT(void) interlace_bmatrix(byte **S0, long nrl, long nrh, long ncl, long nch, byte **S1, byte **D) |
---|
457 | /* ------------------------------------------------------------------------------------------------------- */ |
---|
458 | { |
---|
459 | // S1 & S2 are supposed to have the same height |
---|
460 | int i, i0, i1; |
---|
461 | int j; |
---|
462 | |
---|
463 | i0 = i1 = nrl; |
---|
464 | |
---|
465 | for(i=nrl; i<=nrh;) { |
---|
466 | //dup_bvector(S0[i0++], ncl, nch, D[i++]); |
---|
467 | //dup_bvector(S1[i1++], ncl, nch, D[i++]); |
---|
468 | for(j=ncl; j<=nch; j++) D[i][j] = S0[i0][j]; i++; i0++; |
---|
469 | for(j=ncl; j<=nch; j++) D[i][j] = S0[i1][j]; i++; i1++; |
---|
470 | } |
---|
471 | } |
---|
472 | /* ---------------------------------------------------------------------------------------------------------- */ |
---|
473 | IMAGE_EXPORT(void) interlace_rgb8matrix(rgb8 **S0, long nrl, long nrh, long ncl, long nch, rgb8 **S1, rgb8 **D) |
---|
474 | /* ---------------------------------------------------------------------------------------------------------- */ |
---|
475 | { |
---|
476 | int i, i0, i1; |
---|
477 | int j; |
---|
478 | |
---|
479 | i0 = i1 = nrl; |
---|
480 | |
---|
481 | for(i=nrl; i<=nrh;) { |
---|
482 | //dup_rgb8vector(S0[i0++], ncl, nch, D[i++]); |
---|
483 | //dup_rgb8vector(S1[i1++], ncl, nch, D[i++]); |
---|
484 | for(j=ncl; j<=nch; j++) D[i][j] = S0[i0][j]; i++; i0++; |
---|
485 | for(j=ncl; j<=nch; j++) D[i][j] = S0[i1][j]; i++; i1++; |
---|
486 | } |
---|
487 | } |
---|
488 | |
---|
489 | /* ---------------------------------------------------------------------------------------------- */ |
---|
490 | IMAGE_EXPORT(void) copyc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte **cond, byte c, byte **dst) |
---|
491 | /* ---------------------------------------------------------------------------------------------- */ |
---|
492 | { |
---|
493 | long i, j; |
---|
494 | byte *Xi, *Yi, *Ci; |
---|
495 | |
---|
496 | for(i=nrl; i<=nrh; i++) { |
---|
497 | Xi = src [i]; |
---|
498 | Yi = dst [i]; |
---|
499 | Ci = cond[i]; |
---|
500 | for(j=ncl; j<=nch; j++) { |
---|
501 | if(Ci[j] == c) Yi[j] = Xi[j]; else Yi[j] = 0; |
---|
502 | } |
---|
503 | } |
---|
504 | } |
---|
505 | /* ------------------------------------------------------------------------------ */ |
---|
506 | IMAGE_EXPORT(void) complete_border_ui8matrix(uint8 **m, long nrl,long nrh,long ncl, long nch, long n) |
---|
507 | /* ------------------------------------------------------------------------------ */ |
---|
508 | { |
---|
509 | long i, j; |
---|
510 | |
---|
511 | uint8 *Xi; |
---|
512 | |
---|
513 | for(i=nrl; i<=nrh; i++) { |
---|
514 | Xi = m[i]; |
---|
515 | for(j=1; j<=n; j++) { |
---|
516 | Xi[ncl-j] = Xi[ncl]; |
---|
517 | Xi[nch+j] = Xi[nch]; |
---|
518 | } |
---|
519 | } |
---|
520 | for(i=1; i<=n; i++) |
---|
521 | dup_ui8vector(m[nrl], ncl-n, nch+n, m[nrl-i]); |
---|
522 | for(i=1; i<=n; i++) |
---|
523 | dup_ui8vector(m[nrh], ncl-n, nch+n, m[nrh+i]); |
---|
524 | } |
---|
525 | /* ------------------------------------------------------------------------------------- */ |
---|
526 | IMAGE_EXPORT(void) complete_border1_ui8matrix(uint8 **m, long nrl,long nrh,long ncl, long nch) |
---|
527 | /* ------------------------------------------------------------------------------------- */ |
---|
528 | { |
---|
529 | long i; |
---|
530 | uint8 *Xi; |
---|
531 | |
---|
532 | dup_ui8vector(m[nrl+1], ncl, nch, m[nrl]); |
---|
533 | |
---|
534 | for(i=nrl; i<=nrh; i++) { |
---|
535 | Xi = m[i]; |
---|
536 | Xi[nrl] = Xi[nrl+1]; |
---|
537 | Xi[nrh] = Xi[nrh-1]; |
---|
538 | } |
---|
539 | |
---|
540 | dup_ui8vector(m[nrh-1], ncl, nch, m[nrh]); |
---|
541 | } |
---|
542 | /* ------------------------------------------------------------------------------------- */ |
---|
543 | IMAGE_EXPORT(void) complete_border2_ui8matrix(uint8 **m, long nrl,long nrh,long ncl, long nch) |
---|
544 | /* ------------------------------------------------------------------------------------- */ |
---|
545 | { |
---|
546 | long i; |
---|
547 | uint8 *Xi; |
---|
548 | |
---|
549 | dup_ui8vector(m[nrl+2], ncl, nch, m[nrl+0]); |
---|
550 | dup_ui8vector(m[nrl+2], ncl, nch, m[nrl+1]); |
---|
551 | |
---|
552 | |
---|
553 | for(i=nrl; i<=nrh; i++) { |
---|
554 | Xi = m[i]; |
---|
555 | Xi[nrl] = Xi[nrl+1] = Xi[nrl+2]; |
---|
556 | Xi[nrh] = Xi[nrh-1] = Xi[nrh-2]; |
---|
557 | } |
---|
558 | |
---|
559 | dup_ui8vector(m[nrh-2], ncl, nch, m[nrh-1]); |
---|
560 | dup_ui8vector(m[nrh-2], ncl, nch, m[nrh-0]); |
---|
561 | } |
---|
562 | /* ------------------------------------------------------------------------------------------------ */ |
---|
563 | IMAGE_EXPORT(void) copy1c_ui8matrix(uint8 **X, long nc, uint8 **Y, long nrl, long nrh, long ncl, long nch) |
---|
564 | /* ------------------------------------------------------------------------------------------------ */ |
---|
565 | { |
---|
566 | int i; |
---|
567 | |
---|
568 | for(i=nrl; i<=nrh; i++) { |
---|
569 | //copy1c_ui8vector(X[i], nc, Y[i], ncl, nch); |
---|
570 | } |
---|
571 | } |
---|
572 | /* -------------------------------------------------------------------------------------------------- */ |
---|
573 | IMAGE_EXPORT(void) copy1c_ui16matrix(uint16 **X, long nc, uint16 **Y, long nrl, long nrh, long ncl, long nch) |
---|
574 | /* -------------------------------------------------------------------------------------------------- */ |
---|
575 | { |
---|
576 | int i; |
---|
577 | |
---|
578 | for(i=nrl; i<=nrh; i++) { |
---|
579 | //copy1c_ui16vector(X[i], nc, Y[i], ncl, nch); |
---|
580 | } |
---|
581 | } |
---|
582 | /* ---------------------------------------------------------------------------------------------- */ |
---|
583 | IMAGE_EXPORT(void) copy1c_ui32matrix(uint32 **X, long nc, uint32 **Y, long nrl, long nrh, long ncl, long nch) |
---|
584 | /* ---------------------------------------------------------------------------------------------- */ |
---|
585 | { |
---|
586 | int i; |
---|
587 | |
---|
588 | for(i=nrl; i<=nrh; i++) { |
---|
589 | //copy1c_ui32vector(X[i], nc, Y[i], ncl, nch); |
---|
590 | } |
---|
591 | } |
---|
592 | /* ------------------------------------------------------------------------------------------------- */ |
---|
593 | IMAGE_EXPORT(void) copy1c_f32matrix(float32 **X, long nc, float32 **Y, long nrl, long nrh, long ncl, long nch) |
---|
594 | /* ------------------------------------------------------------------------------------------------- */ |
---|
595 | { |
---|
596 | int i; |
---|
597 | |
---|
598 | for(i=nrl; i<=nrh; i++) { |
---|
599 | //copy1c_f32vector(X[i], nc, Y[i], ncl, nch); |
---|
600 | } |
---|
601 | } |
---|
602 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
603 | IMAGE_EXPORT(void) copy1c_f64matrix(float64 **X, long nc, float64 **Y, long nrl, long nrh, long ncl, long nch) |
---|
604 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
605 | { |
---|
606 | int i; |
---|
607 | |
---|
608 | for(i=nrl; i<=nrh; i++) { |
---|
609 | //copy1c_f64vector(X[i], nc, Y[i], ncl, nch); |
---|
610 | } |
---|
611 | } |
---|
612 | /* --------------------------------------------------------------------------------------------------- */ |
---|
613 | IMAGE_EXPORT(void) copy1c_rgb8matrix(rgb8 **X, long nc, rgb8 **Y, long nrl, long nrh, long ncl, long nch) |
---|
614 | /* --------------------------------------------------------------------------------------------------- */ |
---|
615 | { |
---|
616 | int i; |
---|
617 | |
---|
618 | for(i=nrl; i<=nrh; i++) { |
---|
619 | //copy1c_rgb8vector(X[i], nc, Y[i], ncl, nch); |
---|
620 | } |
---|
621 | } |
---|
622 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
623 | IMAGE_EXPORT(void) copy1c_rgbx8matrix(rgbx8 **X, long nc, rgbx8 **Y, long nrl, long nrh, long ncl, long nch) |
---|
624 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
625 | { |
---|
626 | int i; |
---|
627 | |
---|
628 | for(i=nrl; i<=nrh; i++) { |
---|
629 | //copy1c_rgbx8vector(X[i], nc, Y[i], ncl, nch); |
---|
630 | } |
---|
631 | } |
---|
632 | /* ------------------------------------------------------------------------------------------------ */ |
---|
633 | IMAGE_EXPORT(void) copy1r_ui8matrix(uint8 **X, long nr, uint8 **Y, long nrl, long nrh, long ncl, long nch) |
---|
634 | /* ------------------------------------------------------------------------------------------------ */ |
---|
635 | { |
---|
636 | int i; |
---|
637 | |
---|
638 | for(i=nrl; i<=nrh; i++) { |
---|
639 | dup_ui8vector(X[nr], ncl, nch, Y[i]); |
---|
640 | } |
---|
641 | } |
---|
642 | /* -------------------------------------------------------------------------------------------------- */ |
---|
643 | IMAGE_EXPORT(void) copy1r_ui16matrix(uint16 **X, long nr, uint16 **Y, long nrl, long nrh, long ncl, long nch) |
---|
644 | /* -------------------------------------------------------------------------------------------------- */ |
---|
645 | { |
---|
646 | int i; |
---|
647 | |
---|
648 | for(i=nrl; i<=nrh; i++) { |
---|
649 | dup_ui16vector(X[nr], ncl, nch, Y[i]); |
---|
650 | } |
---|
651 | } |
---|
652 | /* ---------------------------------------------------------------------------------------------- */ |
---|
653 | IMAGE_EXPORT(void) copy1r_ui32matrix(uint32 **X, long nr, uint32 **Y, long nrl, long nrh, long ncl, long nch) |
---|
654 | /* ---------------------------------------------------------------------------------------------- */ |
---|
655 | { |
---|
656 | int i; |
---|
657 | |
---|
658 | for(i=nrl; i<=nrh; i++) { |
---|
659 | dup_ui32vector(X[nr], ncl, nch, Y[i]); |
---|
660 | } |
---|
661 | } |
---|
662 | /* ------------------------------------------------------------------------------------------------- */ |
---|
663 | IMAGE_EXPORT(void) copy1r_f32matrix(float32 **X, long nr, float32 **Y, long nrl, long nrh, long ncl, long nch) |
---|
664 | /* ------------------------------------------------------------------------------------------------- */ |
---|
665 | { |
---|
666 | int i; |
---|
667 | |
---|
668 | for(i=nrl; i<=nrh; i++) { |
---|
669 | dup_f32vector(X[nr], ncl, nch, Y[i]); |
---|
670 | } |
---|
671 | } |
---|
672 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
673 | IMAGE_EXPORT(void) copy1r_f64matrix(float64 **X, long nr, float64 **Y, long nrl, long nrh, long ncl, long nch) |
---|
674 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
675 | { |
---|
676 | int i; |
---|
677 | |
---|
678 | for(i=nrl; i<=nrh; i++) { |
---|
679 | dup_f64vector(X[nr], ncl, nch, Y[i]); |
---|
680 | } |
---|
681 | } |
---|
682 | /* --------------------------------------------------------------------------------------------------- */ |
---|
683 | IMAGE_EXPORT(void) copy1r_rgb8matrix(rgb8 **X, long nr, rgb8 **Y, long nrl, long nrh, long ncl, long nch) |
---|
684 | /* --------------------------------------------------------------------------------------------------- */ |
---|
685 | { |
---|
686 | int i; |
---|
687 | |
---|
688 | for(i=nrl; i<=nrh; i++) { |
---|
689 | dup_rgb8vector(X[nr], ncl, nch, Y[i]); |
---|
690 | } |
---|
691 | } |
---|
692 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
693 | IMAGE_EXPORT(void) copy1r_rgbx8matrix(rgbx8 **X, long nr, rgbx8 **Y, long nrl, long nrh, long ncl, long nch) |
---|
694 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
695 | { |
---|
696 | int i; |
---|
697 | |
---|
698 | for(i=nrl; i<=nrh; i++) { |
---|
699 | dup_rgbx8vector(X[nr], ncl, nch, Y[i]); |
---|
700 | } |
---|
701 | } |
---|