1 | /* ---------------- */ |
---|
2 | /* --- nrio2x.c --- */ |
---|
3 | /* ---------------- */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
7 | * Univ Paris Sud XI, CNRS |
---|
8 | */ |
---|
9 | |
---|
10 | #include <stdio.h> |
---|
11 | #include <stddef.h> |
---|
12 | #include <stdlib.h> |
---|
13 | |
---|
14 | #include "mypredef.h" |
---|
15 | #include "nrtype.h" |
---|
16 | #include "nrdef.h" |
---|
17 | #include "nrmacro.h" |
---|
18 | #include "nrkernel.h" |
---|
19 | |
---|
20 | #include "nrio0.h" |
---|
21 | #include "nralloc1.h" |
---|
22 | #include "nralloc2.h" |
---|
23 | #include "nrio1.h" |
---|
24 | #include "nrio2.h" |
---|
25 | #include "nrio2x.h" |
---|
26 | |
---|
27 | /* ------------------------------ */ |
---|
28 | /* --- display_matrix_endline --- */ |
---|
29 | /* ------------------------------ */ |
---|
30 | /* ----------------------- */ |
---|
31 | /* --- write_trimatrix --- */ |
---|
32 | /* ----------------------- */ |
---|
33 | |
---|
34 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
35 | IMAGE_EXPORT(void) write_btrimatrix(byte **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
36 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
37 | { |
---|
38 | int i,j; |
---|
39 | |
---|
40 | FILE *f; |
---|
41 | |
---|
42 | f = fopen(filename, "wt"); |
---|
43 | if(f == NULL) { |
---|
44 | nrerror("Can't open file in write_btrimatrix"); |
---|
45 | } |
---|
46 | |
---|
47 | for(i=i0; i<=i1; i++) { |
---|
48 | for(j=j0; j<=j1; j++) { |
---|
49 | fprintf(f, format, m[i][j]); |
---|
50 | } |
---|
51 | fputc('\n', f); |
---|
52 | j1 += step; |
---|
53 | } |
---|
54 | fputc('\n', f); |
---|
55 | |
---|
56 | fclose(f); |
---|
57 | } |
---|
58 | |
---|
59 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
60 | IMAGE_EXPORT(void) write_i16trimatrix(int16 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
61 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
62 | { |
---|
63 | int i,j; |
---|
64 | |
---|
65 | FILE *f; |
---|
66 | |
---|
67 | f = fopen(filename, "wt"); |
---|
68 | if(f == NULL) { |
---|
69 | nrerror("Can't open file in write_i16trimatrix"); |
---|
70 | } |
---|
71 | |
---|
72 | for(i=i0; i<=i1; i++) { |
---|
73 | for(j=j0; j<=j1; j++) { |
---|
74 | fprintf(f, format, m[i][j]); |
---|
75 | } |
---|
76 | fputc('\n', f); |
---|
77 | j1 += step; |
---|
78 | } |
---|
79 | fputc('\n', f); |
---|
80 | |
---|
81 | fclose(f); |
---|
82 | } |
---|
83 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
84 | IMAGE_EXPORT(void) write_ui16trimatrix(uint16 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
85 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
86 | { |
---|
87 | int i,j; |
---|
88 | |
---|
89 | FILE *f; |
---|
90 | |
---|
91 | f = fopen(filename, "wt"); |
---|
92 | if(f == NULL) { |
---|
93 | nrerror("Can't open file in write_ui16trimatrix"); |
---|
94 | } |
---|
95 | |
---|
96 | for(i=i0; i<=i1; i++) { |
---|
97 | for(j=j0; j<=j1; j++) { |
---|
98 | fprintf(f, format, m[i][j]); |
---|
99 | } |
---|
100 | fputc('\n', f); |
---|
101 | j1 += step; |
---|
102 | } |
---|
103 | fputc('\n', f); |
---|
104 | |
---|
105 | fclose(f); |
---|
106 | } |
---|
107 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
108 | IMAGE_EXPORT(void) write_itrimatrix(int **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
109 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
110 | { |
---|
111 | int i,j; |
---|
112 | |
---|
113 | FILE *f; |
---|
114 | |
---|
115 | f = fopen(filename, "wt"); |
---|
116 | if(f == NULL) { |
---|
117 | nrerror("Can't open file in write_itrimatrix"); |
---|
118 | } |
---|
119 | |
---|
120 | for(i=i0; i<=i1; i++) { |
---|
121 | for(j=j0; j<=j1; j++) { |
---|
122 | fprintf(f, format, m[i][j]); |
---|
123 | } |
---|
124 | fputc('\n', f); |
---|
125 | j1 += step; |
---|
126 | } |
---|
127 | fputc('\n', f); |
---|
128 | |
---|
129 | fclose(f); |
---|
130 | } |
---|
131 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
132 | IMAGE_EXPORT(void) write_i32trimatrix(int32 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
133 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
134 | { |
---|
135 | int i,j; |
---|
136 | |
---|
137 | FILE *f; |
---|
138 | |
---|
139 | f = fopen(filename, "wt"); |
---|
140 | if(f == NULL) { |
---|
141 | nrerror("Can't open file in write_i32trimatrix"); |
---|
142 | } |
---|
143 | |
---|
144 | for(i=i0; i<=i1; i++) { |
---|
145 | for(j=j0; j<=j1; j++) { |
---|
146 | fprintf(f, format, m[i][j]); |
---|
147 | } |
---|
148 | fputc('\n', f); |
---|
149 | j1 += step; |
---|
150 | } |
---|
151 | fputc('\n', f); |
---|
152 | |
---|
153 | fclose(f); |
---|
154 | } |
---|
155 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
156 | IMAGE_EXPORT(void) write_f32trimatrix(float32 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
157 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
158 | { |
---|
159 | int i,j; |
---|
160 | |
---|
161 | FILE *f; |
---|
162 | |
---|
163 | f = fopen(filename, "wt"); |
---|
164 | if(f == NULL) { |
---|
165 | nrerror("Can't open file in write_f32trimatrix"); |
---|
166 | } |
---|
167 | |
---|
168 | for(i=i0; i<=i1; i++) { |
---|
169 | for(j=j0; j<=j1; j++) { |
---|
170 | fprintf(f, format, m[i][j]); |
---|
171 | } |
---|
172 | fputc('\n', f); |
---|
173 | j1 += step; |
---|
174 | } |
---|
175 | fputc('\n', f); |
---|
176 | |
---|
177 | fclose(f); |
---|
178 | } |
---|
179 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
180 | IMAGE_EXPORT(void) write_f64trimatrix(float64 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename) |
---|
181 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
182 | { |
---|
183 | int i,j; |
---|
184 | |
---|
185 | FILE *f; |
---|
186 | |
---|
187 | f = fopen(filename, "wt"); |
---|
188 | if(f == NULL) { |
---|
189 | nrerror("Can't open file in write_f64trimatrix"); |
---|
190 | } |
---|
191 | |
---|
192 | for(i=i0; i<=i1; i++) { |
---|
193 | for(j=j0; j<=j1; j++) { |
---|
194 | fprintf(f, format, m[i][j]); |
---|
195 | } |
---|
196 | fputc('\n', f); |
---|
197 | j1 += step; |
---|
198 | } |
---|
199 | fputc('\n', f); |
---|
200 | |
---|
201 | fclose(f); |
---|
202 | } |
---|
203 | /* ---------------------------- */ |
---|
204 | /* --- write_matrix_endline --- */ |
---|
205 | /* ---------------------------- */ |
---|
206 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
207 | IMAGE_EXPORT(void) write_bmatrix_endline(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
208 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
209 | { |
---|
210 | int i,j; |
---|
211 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
212 | byte *p = &m[i0][j0]; |
---|
213 | |
---|
214 | FILE *f; |
---|
215 | |
---|
216 | f = fopen(filename, "wt"); |
---|
217 | if(f == NULL) { |
---|
218 | nrerror("Can't open file in write_bmatrix_endline"); |
---|
219 | } |
---|
220 | |
---|
221 | for(i=i0; i<=i1; i++) { |
---|
222 | for(j=j0; j<=j1; j++) { |
---|
223 | fprintf(f, format, *p++); |
---|
224 | } |
---|
225 | fputc('\n', f); |
---|
226 | } |
---|
227 | fclose(f); |
---|
228 | } |
---|
229 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
230 | IMAGE_EXPORT(void) write_i16matrix_endline(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
231 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
232 | { |
---|
233 | int i,j; |
---|
234 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
235 | int16 *p = &m[i0][j0]; |
---|
236 | |
---|
237 | FILE *f; |
---|
238 | |
---|
239 | f = fopen(filename, "wt"); |
---|
240 | if(f == NULL) { |
---|
241 | nrerror("Can't open file in write_i16matrix_endline"); |
---|
242 | } |
---|
243 | |
---|
244 | for(i=i0; i<=i1; i++) { |
---|
245 | for(j=j0; j<=j1; j++) { |
---|
246 | fprintf(f, format, *p++); |
---|
247 | } |
---|
248 | fputc('\n', f); |
---|
249 | } |
---|
250 | fclose(f); |
---|
251 | } |
---|
252 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
253 | IMAGE_EXPORT(void) write_ui16matrix_endline(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
254 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
255 | { |
---|
256 | int i,j; |
---|
257 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
258 | uint16 *p = &m[i0][j0]; |
---|
259 | |
---|
260 | FILE *f; |
---|
261 | |
---|
262 | f = fopen(filename, "wt"); |
---|
263 | if(f == NULL) { |
---|
264 | nrerror("Can't open file in write_ui16matrix_endline"); |
---|
265 | } |
---|
266 | |
---|
267 | for(i=i0; i<=i1; i++) { |
---|
268 | for(j=j0; j<=j1; j++) { |
---|
269 | fprintf(f, format, *p++); |
---|
270 | } |
---|
271 | fputc('\n', f); |
---|
272 | } |
---|
273 | fclose(f); |
---|
274 | } |
---|
275 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
276 | IMAGE_EXPORT(void) write_i32matrix_endline(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
277 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
278 | { |
---|
279 | int i,j; |
---|
280 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
281 | int32 *p = &m[i0][j0]; |
---|
282 | |
---|
283 | FILE *f; |
---|
284 | |
---|
285 | f = fopen(filename, "wt"); |
---|
286 | if(f == NULL) { |
---|
287 | nrerror("Can't open file in write_i32matrix_endline"); |
---|
288 | } |
---|
289 | |
---|
290 | for(i=i0; i<=i1; i++) { |
---|
291 | for(j=j0; j<=j1; j++) { |
---|
292 | fprintf(f, format, *p++); |
---|
293 | } |
---|
294 | fputc('\n', f); |
---|
295 | } |
---|
296 | fclose(f); |
---|
297 | } |
---|
298 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
299 | IMAGE_EXPORT(void) write_ui32matrix_endline(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
300 | /* ------------------------------------------------------------------------------------------------------------------ */ |
---|
301 | { |
---|
302 | int i,j; |
---|
303 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
304 | uint32 *p = &m[i0][j0]; |
---|
305 | |
---|
306 | FILE *f; |
---|
307 | |
---|
308 | f = fopen(filename, "wt"); |
---|
309 | if(f == NULL) { |
---|
310 | nrerror("Can't open file in write_ui32matrix_endline"); |
---|
311 | } |
---|
312 | |
---|
313 | for(i=i0; i<=i1; i++) { |
---|
314 | for(j=j0; j<=j1; j++) { |
---|
315 | fprintf(f, format, *p++); |
---|
316 | } |
---|
317 | fputc('\n', f); |
---|
318 | } |
---|
319 | fclose(f); |
---|
320 | } |
---|
321 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
322 | IMAGE_EXPORT(void) write_i64matrix_endline(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
323 | /* ---------------------------------------------------------------------------------------------------------------- */ |
---|
324 | { |
---|
325 | int i,j; |
---|
326 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
327 | int64 *p = &m[i0][j0]; |
---|
328 | |
---|
329 | FILE *f; |
---|
330 | |
---|
331 | f = fopen(filename, "wt"); |
---|
332 | if(f == NULL) { |
---|
333 | nrerror("Can't open file in write_i64matrix_endline"); |
---|
334 | } |
---|
335 | |
---|
336 | for(i=i0; i<=i1; i++) { |
---|
337 | for(j=j0; j<=j1; j++) { |
---|
338 | fprintf(f, format, *p++); |
---|
339 | } |
---|
340 | fputc('\n', f); |
---|
341 | } |
---|
342 | fclose(f); |
---|
343 | } |
---|
344 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
345 | IMAGE_EXPORT(void) write_imatrix_endline(int **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
346 | /* ------------------------------------------------------------------------------------------------------------ */ |
---|
347 | { |
---|
348 | int i,j; |
---|
349 | //int n = (i1-i0+1) * (j1-j0+1); |
---|
350 | int *p = &m[i0][j0]; |
---|
351 | |
---|
352 | FILE *f; |
---|
353 | |
---|
354 | f = fopen(filename, "wt"); |
---|
355 | if(f == NULL) { |
---|
356 | nrerror("Can't open file in write_imatrix_endline"); |
---|
357 | } |
---|
358 | |
---|
359 | for(i=i0; i<=i1; i++) { |
---|
360 | for(j=j0; j<=j1; j++) { |
---|
361 | fprintf(f, format, *p++); |
---|
362 | } |
---|
363 | fputc('\n', f); |
---|
364 | } |
---|
365 | fclose(f); |
---|
366 | } |
---|
367 | /* ------------------------------ */ |
---|
368 | /* --- write_imatrix_endline0 --- */ |
---|
369 | /* ------------------------------ */ |
---|
370 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
371 | IMAGE_EXPORT(void) write_bmatrix_endline0(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
372 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
373 | { |
---|
374 | int i,j, n; |
---|
375 | |
---|
376 | FILE *f; |
---|
377 | |
---|
378 | f = fopen(filename, "wt"); |
---|
379 | if(f == NULL) { |
---|
380 | nrerror("Can't open file in write_bmatrix_endline0"); |
---|
381 | } |
---|
382 | |
---|
383 | for(i=i0; i<=i1; i++) { |
---|
384 | n = m[i][j0]; |
---|
385 | for(j=j0; j<=j0+n; j++) { |
---|
386 | fprintf(f, format, m[i][j]); |
---|
387 | } |
---|
388 | fputc('\n', f); |
---|
389 | } |
---|
390 | fclose(f); |
---|
391 | } |
---|
392 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
393 | IMAGE_EXPORT(void) write_i16matrix_endline0(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
394 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
395 | { |
---|
396 | int i,j, n; |
---|
397 | |
---|
398 | FILE *f; |
---|
399 | |
---|
400 | f = fopen(filename, "wt"); |
---|
401 | if(f == NULL) { |
---|
402 | nrerror("Can't open file in write_i16matrix_endline0"); |
---|
403 | } |
---|
404 | |
---|
405 | for(i=i0; i<=i1; i++) { |
---|
406 | n = m[i][j0]; |
---|
407 | for(j=j0; j<=j0+n; j++) { |
---|
408 | fprintf(f, format, m[i][j]); |
---|
409 | } |
---|
410 | fputc('\n', f); |
---|
411 | } |
---|
412 | fclose(f); |
---|
413 | } |
---|
414 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
415 | IMAGE_EXPORT(void) write_ui16matrix_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
416 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
417 | { |
---|
418 | int i,j, n; |
---|
419 | |
---|
420 | FILE *f; |
---|
421 | |
---|
422 | f = fopen(filename, "wt"); |
---|
423 | if(f == NULL) { |
---|
424 | nrerror("Can't open file in write_ui16matrix_endline0"); |
---|
425 | } |
---|
426 | |
---|
427 | for(i=i0; i<=i1; i++) { |
---|
428 | n = m[i][j0]; |
---|
429 | for(j=j0; j<=j0+n; j++) { |
---|
430 | fprintf(f, format, m[i][j]); |
---|
431 | } |
---|
432 | fputc('\n', f); |
---|
433 | } |
---|
434 | fclose(f); |
---|
435 | } |
---|
436 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
437 | IMAGE_EXPORT(void) write_i32matrix_endline0(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
438 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
439 | { |
---|
440 | int i,j, n; |
---|
441 | |
---|
442 | FILE *f; |
---|
443 | |
---|
444 | f = fopen(filename, "wt"); |
---|
445 | if(f == NULL) { |
---|
446 | nrerror("Can't open file in write_i32matrix_endline0"); |
---|
447 | } |
---|
448 | |
---|
449 | for(i=i0; i<=i1; i++) { |
---|
450 | n = m[i][j0]; |
---|
451 | for(j=j0; j<=j0+n; j++) { |
---|
452 | fprintf(f, format, m[i][j]); |
---|
453 | } |
---|
454 | fputc('\n', f); |
---|
455 | } |
---|
456 | fclose(f); |
---|
457 | } |
---|
458 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
459 | IMAGE_EXPORT(void) write_i64matrix_endline0(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
460 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
461 | { |
---|
462 | int i,j; |
---|
463 | int64 n; |
---|
464 | |
---|
465 | FILE *f; |
---|
466 | |
---|
467 | f = fopen(filename, "wt"); |
---|
468 | if(f == NULL) { |
---|
469 | nrerror("Can't open file in write_i64matrix_endline0"); |
---|
470 | } |
---|
471 | |
---|
472 | for(i=i0; i<=i1; i++) { |
---|
473 | n = m[i][j0]; |
---|
474 | for(j=j0; j<=j0+n; j++) { |
---|
475 | fprintf(f, format, m[i][j]); |
---|
476 | } |
---|
477 | fputc('\n', f); |
---|
478 | } |
---|
479 | fclose(f); |
---|
480 | } |
---|
481 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
482 | IMAGE_EXPORT(void) write_ui32matrix_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
483 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
484 | { |
---|
485 | int i,j, n; |
---|
486 | |
---|
487 | FILE *f; |
---|
488 | |
---|
489 | f = fopen(filename, "wt"); |
---|
490 | if(f == NULL) { |
---|
491 | nrerror("Can't open file in write_ui32matrix_endline0"); |
---|
492 | } |
---|
493 | |
---|
494 | for(i=i0; i<=i1; i++) { |
---|
495 | n = m[i][j0]; |
---|
496 | for(j=j0; j<=j0+n; j++) { |
---|
497 | fprintf(f, format, m[i][j]); |
---|
498 | } |
---|
499 | fputc('\n', f); |
---|
500 | } |
---|
501 | fclose(f); |
---|
502 | } |
---|
503 | /* ------------------------------------------------------------------------------------------------------------- */ |
---|
504 | IMAGE_EXPORT(void) write_imatrix_endline0(int **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
505 | /* ------------------------------------------------------------------------------------------------------------- */ |
---|
506 | { |
---|
507 | int i,j, n; |
---|
508 | |
---|
509 | FILE *f; |
---|
510 | |
---|
511 | f = fopen(filename, "wt"); |
---|
512 | if(f == NULL) { |
---|
513 | nrerror("Can't open file in write_imatrix_endline0"); |
---|
514 | } |
---|
515 | |
---|
516 | for(i=i0; i<=i1; i++) { |
---|
517 | n = m[i][j0]; |
---|
518 | for(j=j0; j<=j0+n; j++) { |
---|
519 | fprintf(f, format, m[i][j]); |
---|
520 | } |
---|
521 | fputc('\n', f); |
---|
522 | } |
---|
523 | fclose(f); |
---|
524 | } |
---|
525 | /* ------------------------------ */ |
---|
526 | /* --- write_imatrix_endline1 --- */ |
---|
527 | /* ------------------------------ */ |
---|
528 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
529 | IMAGE_EXPORT(void) write_bmatrix_endline1(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
530 | /* -------------------------------------------------------------------------------------------------------------- */ |
---|
531 | { |
---|
532 | int i,j, n; |
---|
533 | |
---|
534 | FILE *f; |
---|
535 | |
---|
536 | f = fopen(filename, "wt"); |
---|
537 | if(f == NULL) { |
---|
538 | nrerror("Can't open file in write_bmatrix_endline1"); |
---|
539 | } |
---|
540 | |
---|
541 | for(i=i0; i<=i1; i++) { |
---|
542 | n = m[i][j0-1]; |
---|
543 | for(j=j0; j<=j0+n-1; j++) { |
---|
544 | fprintf(f, format, m[i][j]); |
---|
545 | } |
---|
546 | fputc('\n', f); |
---|
547 | } |
---|
548 | fclose(f); |
---|
549 | } |
---|
550 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
551 | IMAGE_EXPORT(void) write_i16matrix_endline1(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
552 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
553 | { |
---|
554 | int i,j, n; |
---|
555 | |
---|
556 | FILE *f; |
---|
557 | |
---|
558 | f = fopen(filename, "wt"); |
---|
559 | if(f == NULL) { |
---|
560 | nrerror("Can't open file in write_i16matrix_endline0"); |
---|
561 | } |
---|
562 | |
---|
563 | for(i=i0; i<=i1; i++) { |
---|
564 | n = m[i][j0-1]; |
---|
565 | for(j=j0; j<=j0+n-1; j++) { |
---|
566 | fprintf(f, format, m[i][j]); |
---|
567 | } |
---|
568 | fputc('\n', f); |
---|
569 | } |
---|
570 | fclose(f); |
---|
571 | } |
---|
572 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
573 | IMAGE_EXPORT(void) write_ui16matrix_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
574 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
575 | { |
---|
576 | int i,j, n; |
---|
577 | |
---|
578 | FILE *f; |
---|
579 | |
---|
580 | f = fopen(filename, "wt"); |
---|
581 | if(f == NULL) { |
---|
582 | nrerror("Can't open file in write_ui16matrix_endline0"); |
---|
583 | } |
---|
584 | |
---|
585 | for(i=i0; i<=i1; i++) { |
---|
586 | n = m[i][j0-1]; |
---|
587 | for(j=j0; j<=j0+n-1; j++) { |
---|
588 | fprintf(f, format, m[i][j]); |
---|
589 | } |
---|
590 | fputc('\n', f); |
---|
591 | } |
---|
592 | fclose(f); |
---|
593 | } |
---|
594 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
595 | IMAGE_EXPORT(void) write_i32matrix_endline1(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
596 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
597 | { |
---|
598 | int i,j, n; |
---|
599 | |
---|
600 | FILE *f; |
---|
601 | |
---|
602 | f = fopen(filename, "wt"); |
---|
603 | if(f == NULL) { |
---|
604 | nrerror("Can't open file in write_i32matrix_endline0"); |
---|
605 | } |
---|
606 | |
---|
607 | for(i=i0; i<=i1; i++) { |
---|
608 | n = m[i][j0-1]; |
---|
609 | for(j=j0; j<=j0+n-1; j++) { |
---|
610 | fprintf(f, format, m[i][j]); |
---|
611 | } |
---|
612 | fputc('\n', f); |
---|
613 | } |
---|
614 | fclose(f); |
---|
615 | } |
---|
616 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
617 | IMAGE_EXPORT(void) write_ui32matrix_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
618 | /* ------------------------------------------------------------------------------------------------------------------- */ |
---|
619 | { |
---|
620 | int i,j, n; |
---|
621 | |
---|
622 | FILE *f; |
---|
623 | |
---|
624 | f = fopen(filename, "wt"); |
---|
625 | if(f == NULL) { |
---|
626 | nrerror("Can't open file in write_ui32matrix_endline0"); |
---|
627 | } |
---|
628 | |
---|
629 | for(i=i0; i<=i1; i++) { |
---|
630 | n = m[i][j0-1]; |
---|
631 | for(j=j0; j<=j0+n-1; j++) { |
---|
632 | fprintf(f, format, m[i][j]); |
---|
633 | } |
---|
634 | fputc('\n', f); |
---|
635 | } |
---|
636 | fclose(f); |
---|
637 | } |
---|
638 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
639 | IMAGE_EXPORT(void) write_i64matrix_endline1(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
640 | /* ----------------------------------------------------------------------------------------------------------------- */ |
---|
641 | { |
---|
642 | int i,j; |
---|
643 | int64 n; |
---|
644 | |
---|
645 | FILE *f; |
---|
646 | |
---|
647 | f = fopen(filename, "wt"); |
---|
648 | if(f == NULL) { |
---|
649 | nrerror("Can't open file in write_i64matrix_endline0"); |
---|
650 | } |
---|
651 | |
---|
652 | for(i=i0; i<=i1; i++) { |
---|
653 | n = m[i][j0-1]; |
---|
654 | for(j=j0; j<=j0+n-1; j++) { |
---|
655 | fprintf(f, format, m[i][j]); |
---|
656 | } |
---|
657 | fputc('\n', f); |
---|
658 | } |
---|
659 | fclose(f); |
---|
660 | } |
---|
661 | /* ------------------------------------------------------------------------------------------------------------- */ |
---|
662 | IMAGE_EXPORT(void) write_imatrix_endline1(int **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
663 | /* ------------------------------------------------------------------------------------------------------------- */ |
---|
664 | { |
---|
665 | int i,j, n; |
---|
666 | |
---|
667 | FILE *f; |
---|
668 | |
---|
669 | f = fopen(filename, "wt"); |
---|
670 | if(f == NULL) { |
---|
671 | nrerror("Can't open file in write_imatrix_endline0"); |
---|
672 | } |
---|
673 | |
---|
674 | for(i=i0; i<=i1; i++) { |
---|
675 | n = m[i][j0-1]; |
---|
676 | for(j=j0; j<=j0+n-1; j++) { |
---|
677 | fprintf(f, format, m[i][j]); |
---|
678 | } |
---|
679 | fputc('\n', f); |
---|
680 | } |
---|
681 | fclose(f); |
---|
682 | } |
---|
683 | /* ------------------------------------- */ |
---|
684 | /* --- write_imatrix_number_endline0 --- */ |
---|
685 | /* ------------------------------------- */ |
---|
686 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
687 | IMAGE_EXPORT(void) write_bmatrix_number_endline0(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
688 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
689 | { |
---|
690 | int i,j, n; |
---|
691 | |
---|
692 | FILE *f; |
---|
693 | |
---|
694 | f = fopen(filename, "wt"); |
---|
695 | if(f == NULL) { |
---|
696 | nrerror("Can't open file in write_bmatrix_number_endline0"); |
---|
697 | } |
---|
698 | |
---|
699 | for(i=i0; i<=i1; i++) { |
---|
700 | fprintf(f, "[%3d] ", i); |
---|
701 | n = m[i][j0]; |
---|
702 | for(j=j0; j<=j0+n; j++) { |
---|
703 | fprintf(f, format, m[i][j]); |
---|
704 | } |
---|
705 | fputc('\n', f); |
---|
706 | } |
---|
707 | fclose(f); |
---|
708 | } |
---|
709 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
---|
710 | IMAGE_EXPORT(void) write_i16matrix_number_endline0(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
711 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
712 | { |
---|
713 | int i,j, n; |
---|
714 | |
---|
715 | FILE *f; |
---|
716 | |
---|
717 | f = fopen(filename, "wt"); |
---|
718 | if(f == NULL) { |
---|
719 | nrerror("Can't open file in write_i16matrix_number_endline0"); |
---|
720 | } |
---|
721 | |
---|
722 | for(i=i0; i<=i1; i++) { |
---|
723 | fprintf(f, "[%3d] ", i); |
---|
724 | n = m[i][j0]; |
---|
725 | for(j=j0; j<=j0+n; j++) { |
---|
726 | fprintf(f, format, m[i][j]); |
---|
727 | } |
---|
728 | fputc('\n', f); |
---|
729 | } |
---|
730 | fclose(f); |
---|
731 | } |
---|
732 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
733 | IMAGE_EXPORT(void) write_ui16matrix_number_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
734 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
735 | { |
---|
736 | int i,j, n; |
---|
737 | |
---|
738 | FILE *f; |
---|
739 | |
---|
740 | f = fopen(filename, "wt"); |
---|
741 | if(f == NULL) { |
---|
742 | nrerror("Can't open file in write_ui16matrix_number_endline0"); |
---|
743 | } |
---|
744 | |
---|
745 | for(i=i0; i<=i1; i++) { |
---|
746 | fprintf(f, "[%3d] ", i); |
---|
747 | n = m[i][j0]; |
---|
748 | for(j=j0; j<=j0+n; j++) { |
---|
749 | fprintf(f, format, m[i][j]); |
---|
750 | } |
---|
751 | fputc('\n', f); |
---|
752 | } |
---|
753 | fclose(f); |
---|
754 | } |
---|
755 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
756 | IMAGE_EXPORT(void) write_i32matrix_number_endline0(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
757 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
758 | { |
---|
759 | int i,j, n; |
---|
760 | |
---|
761 | FILE *f; |
---|
762 | |
---|
763 | f = fopen(filename, "wt"); |
---|
764 | if(f == NULL) { |
---|
765 | nrerror("Can't open file in write_i32matrix_number_endline0"); |
---|
766 | } |
---|
767 | |
---|
768 | for(i=i0; i<=i1; i++) { |
---|
769 | fprintf(f, "[%3d] ", i); |
---|
770 | n = m[i][j0]; |
---|
771 | for(j=j0; j<=j0+n; j++) { |
---|
772 | fprintf(f, format, m[i][j]); |
---|
773 | } |
---|
774 | fputc('\n', f); |
---|
775 | } |
---|
776 | fclose(f); |
---|
777 | } |
---|
778 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
779 | IMAGE_EXPORT(void) write_ui32matrix_number_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
780 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
781 | { |
---|
782 | int i,j, n; |
---|
783 | |
---|
784 | FILE *f; |
---|
785 | |
---|
786 | f = fopen(filename, "wt"); |
---|
787 | if(f == NULL) { |
---|
788 | nrerror("Can't open file in write_ui32matrix_number_endline0"); |
---|
789 | } |
---|
790 | |
---|
791 | for(i=i0; i<=i1; i++) { |
---|
792 | fprintf(f, "[%3d] ", i); |
---|
793 | n = m[i][j0]; |
---|
794 | for(j=j0; j<=j0+n; j++) { |
---|
795 | fprintf(f, format, m[i][j]); |
---|
796 | } |
---|
797 | fputc('\n', f); |
---|
798 | } |
---|
799 | fclose(f); |
---|
800 | } |
---|
801 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
802 | IMAGE_EXPORT(void) write_i64matrix_number_endline0(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
803 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
804 | { |
---|
805 | int i,j; |
---|
806 | int64 n; |
---|
807 | |
---|
808 | FILE *f; |
---|
809 | |
---|
810 | f = fopen(filename, "wt"); |
---|
811 | if(f == NULL) { |
---|
812 | nrerror("Can't open file in write_i64matrix_number_endline0"); |
---|
813 | } |
---|
814 | |
---|
815 | for(i=i0; i<=i1; i++) { |
---|
816 | fprintf(f, "[%3d] ", i); |
---|
817 | n = m[i][j0]; |
---|
818 | for(j=j0; j<=j0+n; j++) { |
---|
819 | fprintf(f, format, m[i][j]); |
---|
820 | } |
---|
821 | fputc('\n', f); |
---|
822 | } |
---|
823 | fclose(f); |
---|
824 | } |
---|
825 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
826 | IMAGE_EXPORT(void) write_imatrix_number_endline0(int **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
827 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
828 | { |
---|
829 | int i,j, n; |
---|
830 | |
---|
831 | FILE *f; |
---|
832 | |
---|
833 | f = fopen(filename, "wt"); |
---|
834 | if(f == NULL) { |
---|
835 | nrerror("Can't open file in write_imatrix_number_endline0"); |
---|
836 | } |
---|
837 | |
---|
838 | for(i=i0; i<=i1; i++) { |
---|
839 | fprintf(f, "[%3d] ", i); |
---|
840 | n = m[i][j0]; |
---|
841 | for(j=j0; j<=j0+n; j++) { |
---|
842 | fprintf(f, format, m[i][j]); |
---|
843 | } |
---|
844 | fputc('\n', f); |
---|
845 | } |
---|
846 | fclose(f); |
---|
847 | } |
---|
848 | /* ------------------------------------- */ |
---|
849 | /* --- write_imatrix_number_endline1 --- */ |
---|
850 | /* ------------------------------------- */ |
---|
851 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
852 | IMAGE_EXPORT(void) write_bmatrix_number_endline1(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
853 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
854 | { |
---|
855 | int i,j, n; |
---|
856 | |
---|
857 | FILE *f; |
---|
858 | |
---|
859 | f = fopen(filename, "wt"); |
---|
860 | if(f == NULL) { |
---|
861 | nrerror("Can't open file in write_bmatrix_number_endline1"); |
---|
862 | } |
---|
863 | |
---|
864 | for(i=i0; i<=i1; i++) { |
---|
865 | fprintf(f, "[%3d] ", i); |
---|
866 | n = m[i][j0-1]; |
---|
867 | for(j=j0; j<=j0+n-1; j++) { |
---|
868 | fprintf(f, format, m[i][j]); |
---|
869 | } |
---|
870 | fputc('\n', f); |
---|
871 | } |
---|
872 | fclose(f); |
---|
873 | } |
---|
874 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
875 | IMAGE_EXPORT(void) write_i16matrix_number_endline1(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
876 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
877 | { |
---|
878 | int i,j, n; |
---|
879 | |
---|
880 | FILE *f; |
---|
881 | |
---|
882 | f = fopen(filename, "wt"); |
---|
883 | if(f == NULL) { |
---|
884 | nrerror("Can't open file in write_i16matrix_number_endline0"); |
---|
885 | } |
---|
886 | |
---|
887 | for(i=i0; i<=i1; i++) { |
---|
888 | fprintf(f, "[%3d] ", i); |
---|
889 | n = m[i][j0-1]; |
---|
890 | for(j=j0; j<=j0+n-1; j++) { |
---|
891 | fprintf(f, format, m[i][j]); |
---|
892 | } |
---|
893 | fputc('\n', f); |
---|
894 | } |
---|
895 | fclose(f); |
---|
896 | } |
---|
897 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
898 | IMAGE_EXPORT(void) write_ui16matrix_number_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
899 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
900 | { |
---|
901 | int i,j, n; |
---|
902 | |
---|
903 | FILE *f; |
---|
904 | |
---|
905 | f = fopen(filename, "wt"); |
---|
906 | if(f == NULL) { |
---|
907 | nrerror("Can't open file in write_ui16matrix_number_endline0"); |
---|
908 | } |
---|
909 | |
---|
910 | for(i=i0; i<=i1; i++) { |
---|
911 | fprintf(f, "[%3d] ", i); |
---|
912 | n = m[i][j0-1]; |
---|
913 | for(j=j0; j<=j0+n-1; j++) { |
---|
914 | fprintf(f, format, m[i][j]); |
---|
915 | } |
---|
916 | fputc('\n', f); |
---|
917 | } |
---|
918 | fclose(f); |
---|
919 | } |
---|
920 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
921 | IMAGE_EXPORT(void) write_i32matrix_number_endline1(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
922 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
923 | { |
---|
924 | int i,j, n; |
---|
925 | |
---|
926 | FILE *f; |
---|
927 | |
---|
928 | f = fopen(filename, "wt"); |
---|
929 | if(f == NULL) { |
---|
930 | nrerror("Can't open file in write_i32matrix_number_endline0"); |
---|
931 | } |
---|
932 | |
---|
933 | for(i=i0; i<=i1; i++) { |
---|
934 | fprintf(f, "[%3d] ", i); |
---|
935 | n = m[i][j0-1]; |
---|
936 | for(j=j0; j<=j0+n-1; j++) { |
---|
937 | fprintf(f, format, m[i][j]); |
---|
938 | } |
---|
939 | fputc('\n', f); |
---|
940 | } |
---|
941 | fclose(f); |
---|
942 | } |
---|
943 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
944 | IMAGE_EXPORT(void) write_ui32matrix_number_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
945 | /* -------------------------------------------------------------------------------------------------------------------------- */ |
---|
946 | { |
---|
947 | int i,j, n; |
---|
948 | |
---|
949 | FILE *f; |
---|
950 | |
---|
951 | f = fopen(filename, "wt"); |
---|
952 | if(f == NULL) { |
---|
953 | nrerror("Can't open file in write_ui32matrix_number_endline0"); |
---|
954 | } |
---|
955 | |
---|
956 | for(i=i0; i<=i1; i++) { |
---|
957 | fprintf(f, "[%3d] ", i); |
---|
958 | n = m[i][j0-1]; |
---|
959 | for(j=j0; j<=j0+n-1; j++) { |
---|
960 | fprintf(f, format, m[i][j]); |
---|
961 | } |
---|
962 | fputc('\n', f); |
---|
963 | } |
---|
964 | fclose(f); |
---|
965 | } |
---|
966 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
967 | IMAGE_EXPORT(void) write_i64matrix_number_endline1(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
968 | /* ------------------------------------------------------------------------------------------------------------------------ */ |
---|
969 | { |
---|
970 | int i,j; |
---|
971 | int64 n; |
---|
972 | |
---|
973 | FILE *f; |
---|
974 | |
---|
975 | f = fopen(filename, "wt"); |
---|
976 | if(f == NULL) { |
---|
977 | nrerror("Can't open file in write_i64matrix_number_endline0"); |
---|
978 | } |
---|
979 | |
---|
980 | for(i=i0; i<=i1; i++) { |
---|
981 | fprintf(f, "[%3d] ", i); |
---|
982 | n = m[i][j0-1]; |
---|
983 | for(j=j0; j<=j0+n-1; j++) { |
---|
984 | fprintf(f, format, m[i][j]); |
---|
985 | } |
---|
986 | fputc('\n', f); |
---|
987 | } |
---|
988 | fclose(f); |
---|
989 | } |
---|
990 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
991 | IMAGE_EXPORT(void) write_imatrix_number_endline1(int **m,long i0, long i1, long j0, long j1, char *format, char *filename) |
---|
992 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
993 | { |
---|
994 | int i,j, n; |
---|
995 | |
---|
996 | FILE *f; |
---|
997 | |
---|
998 | f = fopen(filename, "wt"); |
---|
999 | if(f == NULL) { |
---|
1000 | nrerror("Can't open file in write_imatrix_number_endline0"); |
---|
1001 | } |
---|
1002 | |
---|
1003 | for(i=i0; i<=i1; i++) { |
---|
1004 | fprintf(f, "[%3d] ", i); |
---|
1005 | n = m[i][j0-1]; |
---|
1006 | for(j=j0; j<=j0+n-1; j++) { |
---|
1007 | fprintf(f, format, m[i][j]); |
---|
1008 | } |
---|
1009 | fputc('\n', f); |
---|
1010 | } |
---|
1011 | fclose(f); |
---|
1012 | } |
---|
1013 | /* ---------------------- */ |
---|
1014 | /* -- fwrite_trimatrix -- */ |
---|
1015 | /* ---------------------- */ |
---|
1016 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1017 | IMAGE_EXPORT(void) fwrite_btrimatrix(byte **m,long i0,long i1,long j0, long j1, long step, char *filename) |
---|
1018 | /* ---------------------------------------------------------------------------------------------------- */ |
---|
1019 | { |
---|
1020 | long i, ncol = j1-j0+1; |
---|
1021 | FILE *f; |
---|
1022 | |
---|
1023 | f = fopen(filename, "wb"); |
---|
1024 | if(f == NULL) nrerror("Can't open file in fwrite_btrimatrix"); |
---|
1025 | |
---|
1026 | for(i=i0; i<=i1; i++) { |
---|
1027 | fwrite(m[i]+j0, sizeof(byte), ncol, f); |
---|
1028 | ncol += step; |
---|
1029 | } |
---|
1030 | fclose(f); |
---|
1031 | } |
---|
1032 | /* ------------------------------------------------------------------------------------------------------- */ |
---|
1033 | IMAGE_EXPORT(void) fwrite_i16trimatrix(int16 **m,long i0,long i1,long j0, long j1, long step, char *filename) |
---|
1034 | /* ------------------------------------------------------------------------------------------------------- */ |
---|
1035 | { |
---|
1036 | long i, ncol = j1-j0+1; |
---|
1037 | FILE *f; |
---|
1038 | |
---|
1039 | f = fopen(filename, "wb"); |
---|
1040 | if(f == NULL) nrerror("Can't open file in fwrite_i16trimatrix"); |
---|
1041 | |
---|
1042 | for(i=i0; i<=i1; i++) { |
---|
1043 | fwrite(m[i]+j0, sizeof(int16), ncol, f); |
---|
1044 | ncol += step; |
---|
1045 | } |
---|
1046 | fclose(f); |
---|
1047 | } |
---|
1048 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
1049 | IMAGE_EXPORT(void) fwrite_ui16trimatrix(uint16 **m,long i0,long i1,long j0, long j1, long step, char *filename) |
---|
1050 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
1051 | { |
---|
1052 | long i, ncol = j1-j0+1; |
---|
1053 | FILE *f; |
---|
1054 | |
---|
1055 | f = fopen(filename, "wb"); |
---|
1056 | if(f == NULL) nrerror("Can't open file in fwrite_ui16trimatrix"); |
---|
1057 | |
---|
1058 | for(i=i0; i<=i1; i++) { |
---|
1059 | fwrite(m[i]+j0, sizeof(uint16), ncol, f); |
---|
1060 | ncol += step; |
---|
1061 | } |
---|
1062 | fclose(f); |
---|
1063 | } |
---|
1064 | /* ------------------------------------------------------------------------------------------------------- */ |
---|
1065 | IMAGE_EXPORT(void) fwrite_i32trimatrix(int32 **m,long i0,long i1,long j0, long j1, long step, char *filename) |
---|
1066 | /* ------------------------------------------------------------------------------------------------------- */ |
---|
1067 | { |
---|
1068 | long i, ncol = j1-j0+1; |
---|
1069 | FILE *f; |
---|
1070 | |
---|
1071 | f = fopen(filename, "wb"); |
---|
1072 | if(f == NULL) nrerror("Can't open file in fwrite_i32trimatrix"); |
---|
1073 | |
---|
1074 | for(i=i0; i<=i1; i++) { |
---|
1075 | fwrite(m[i]+j0, sizeof(int32), ncol, f); |
---|
1076 | ncol += step; |
---|
1077 | } |
---|
1078 | fclose(f); |
---|
1079 | } |
---|
1080 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
1081 | IMAGE_EXPORT(void) fwrite_f32trimatrix(float32 **m,long i0,long i1,long j0, long j1, long step, char *filename) |
---|
1082 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
1083 | { |
---|
1084 | long i, ncol = j1-j0+1; |
---|
1085 | FILE *f; |
---|
1086 | |
---|
1087 | f = fopen(filename, "wb"); |
---|
1088 | if(f == NULL) nrerror("Can't open file in fwrite_f32trimatrix"); |
---|
1089 | |
---|
1090 | for(i=i0; i<=i1; i++) { |
---|
1091 | fwrite(m[i]+j0, sizeof(float32), ncol, f); |
---|
1092 | ncol += step; |
---|
1093 | } |
---|
1094 | fclose(f); |
---|
1095 | } |
---|
1096 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
1097 | IMAGE_EXPORT(void) fwrite_f64trimatrix(float64 **m,long i0,long i1,long j0, long j1, long step, char *filename) |
---|
1098 | /* --------------------------------------------------------------------------------------------------------- */ |
---|
1099 | { |
---|
1100 | long i, ncol = j1-j0+1; |
---|
1101 | FILE *f; |
---|
1102 | |
---|
1103 | f = fopen(filename, "wb"); |
---|
1104 | if(f == NULL) nrerror("Can't open file in fwrite_f64trimatrix"); |
---|
1105 | |
---|
1106 | for(i=i0; i<=i1; i++) { |
---|
1107 | fwrite(m[i]+j0, sizeof(float64), ncol, f); |
---|
1108 | } |
---|
1109 | fclose(f); |
---|
1110 | } |
---|
1111 | |
---|
1112 | /* --------------------- */ |
---|
1113 | /* -- fread_trimatrix -- */ |
---|
1114 | /* --------------------- */ |
---|
1115 | /* --------------------------------------------------------------------------------------------------- */ |
---|
1116 | IMAGE_EXPORT(void) fread_btrimatrix(char *filename, byte **m,long i0,long i1,long j0, long j1, long step) |
---|
1117 | /* --------------------------------------------------------------------------------------------------- */ |
---|
1118 | { |
---|
1119 | long i, ncol = j1-j0+1, nread; |
---|
1120 | FILE *f; |
---|
1121 | |
---|
1122 | f = fopen(filename, "rb"); |
---|
1123 | if(f == NULL) nrerror("Can't open file in fread_btrimatrix"); |
---|
1124 | |
---|
1125 | for(i=i0; i<=i1; i++) { |
---|
1126 | nread = fread(m[i]+j0, sizeof(byte), ncol, f); |
---|
1127 | if(nread != ncol) nrerror("fread_btrimatrix : can't read data"); |
---|
1128 | ncol += step; |
---|
1129 | } |
---|
1130 | fclose(f); |
---|
1131 | } |
---|
1132 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1133 | IMAGE_EXPORT(void) fread_i16trimatrix(char *filename, int16 **m,long i0,long i1,long j0, long j1, long step) |
---|
1134 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1135 | { |
---|
1136 | long i, ncol = j1-j0+1, nread; |
---|
1137 | FILE *f; |
---|
1138 | |
---|
1139 | f = fopen(filename, "rb"); |
---|
1140 | if(f == NULL) nrerror("Can't open file in fread_i16trimatrix"); |
---|
1141 | |
---|
1142 | for(i=i0; i<=i1; i++) { |
---|
1143 | nread = fread(m[i]+j0, sizeof(int16), ncol, f); |
---|
1144 | if(nread != ncol) nrerror("fread_i16trimatrix : can't read data"); |
---|
1145 | ncol += step; |
---|
1146 | } |
---|
1147 | fclose(f); |
---|
1148 | } |
---|
1149 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
1150 | IMAGE_EXPORT(void) fread_ui16trimatrix(char *filename, uint16 **m,long i0,long i1,long j0, long j1, long step) |
---|
1151 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
1152 | { |
---|
1153 | long i, ncol = j1-j0+1, nread; |
---|
1154 | FILE *f; |
---|
1155 | |
---|
1156 | f = fopen(filename, "rb"); |
---|
1157 | if(f == NULL) nrerror("Can't open file in fread_ui16trimatrix"); |
---|
1158 | |
---|
1159 | for(i=i0; i<=i1; i++) { |
---|
1160 | nread = fread(m[i]+j0, sizeof(uint16), ncol, f); |
---|
1161 | if(nread != ncol) nrerror("fread_ui16trimatrix : can't read data"); |
---|
1162 | ncol += step; |
---|
1163 | } |
---|
1164 | fclose(f); |
---|
1165 | } |
---|
1166 | /* -------------------------------------------------------------------------------------------------- */ |
---|
1167 | IMAGE_EXPORT(void) fread_itrimatrix(char *filename, int **m,long i0,long i1,long j0, long j1, long step) |
---|
1168 | /* -------------------------------------------------------------------------------------------------- */ |
---|
1169 | { |
---|
1170 | long i, ncol = j1-j0+1, nread; |
---|
1171 | FILE *f; |
---|
1172 | |
---|
1173 | f = fopen(filename, "rb"); |
---|
1174 | if(f == NULL) nrerror("Can't open file in fread_itrimatrix"); |
---|
1175 | |
---|
1176 | for(i=i0; i<=i1; i++) { |
---|
1177 | nread = fread(m[i]+j0, sizeof(int), ncol, f); |
---|
1178 | if(nread != ncol) nrerror("fread_itrimatrix : can't read data"); |
---|
1179 | ncol += step; |
---|
1180 | } |
---|
1181 | fclose(f); |
---|
1182 | } |
---|
1183 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1184 | IMAGE_EXPORT(void) fread_i32trimatrix(char *filename, int32 **m,long i0,long i1,long j0, long j1, long step) |
---|
1185 | /* ------------------------------------------------------------------------------------------------------ */ |
---|
1186 | { |
---|
1187 | long i, ncol = j1-j0+1, nread; |
---|
1188 | FILE *f; |
---|
1189 | |
---|
1190 | f = fopen(filename, "rb"); |
---|
1191 | if(f == NULL) nrerror("Can't open file in fread_i32trimatrix"); |
---|
1192 | |
---|
1193 | for(i=i0; i<=i1; i++) { |
---|
1194 | nread = fread(m[i]+j0, sizeof(byte), ncol, f); |
---|
1195 | if(nread != ncol) nrerror("fread_i32trimatrix : can't read data"); |
---|
1196 | ncol += step; |
---|
1197 | } |
---|
1198 | fclose(f); |
---|
1199 | } |
---|
1200 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
1201 | IMAGE_EXPORT(void) fread_f32trimatrix(char *filename, float32 **m,long i0,long i1,long j0, long j1, long step) |
---|
1202 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
1203 | { |
---|
1204 | long i, ncol = j1-j0+1, nread; |
---|
1205 | FILE *f; |
---|
1206 | |
---|
1207 | f = fopen(filename, "rb"); |
---|
1208 | if(f == NULL) nrerror("Can't open file in fread_f32trimatrix"); |
---|
1209 | |
---|
1210 | for(i=i0; i<=i1; i++) { |
---|
1211 | nread = fread(m[i]+j0, sizeof(byte), ncol, f); |
---|
1212 | if(nread != ncol) nrerror("fread_f32trimatrix : can't read data"); |
---|
1213 | ncol += step; |
---|
1214 | } |
---|
1215 | fclose(f); |
---|
1216 | } |
---|
1217 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
1218 | IMAGE_EXPORT(void) fread_f64trimatrix(char *filename, float64 **m,long i0,long i1,long j0, long j1, long step) |
---|
1219 | /* -------------------------------------------------------------------------------------------------------- */ |
---|
1220 | { |
---|
1221 | long i, ncol = j1-j0+1, nread; |
---|
1222 | FILE *f; |
---|
1223 | |
---|
1224 | f = fopen(filename, "rb"); |
---|
1225 | if(f == NULL) nrerror("Can't open file in fread_f64trimatrix"); |
---|
1226 | |
---|
1227 | for(i=i0; i<=i1; i++) { |
---|
1228 | nread = fread(m[i]+j0, sizeof(byte), ncol, f); |
---|
1229 | if(nread != ncol) nrerror("fread_f64trimatrix : can't read data"); |
---|
1230 | ncol += step; |
---|
1231 | } |
---|
1232 | fclose(f); |
---|
1233 | } |
---|