source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrarith2x.c @ 772

Last change on this file since 772 was 772, checked in by meunier, 8 years ago
  • Ajout de l'application rosenfeld
  • Changement du nom du flag O_CREATE en O_CREAT
File size: 2.8 KB
Line 
1/* ------------------ */
2/* --- nrarith2.c --- */
3/* ------------------ */
4
5/*
6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
7 * Univ Paris Sud XI, CNRS
8 *
9 * Distributed under the Boost Software License, Version 1.0
10 * see accompanying file LICENSE.txt or copy it at
11 * http://www.boost.org/LICENSE_1_0.txt
12 */
13
14#include <stdio.h>
15#include <stddef.h>
16#include <stdlib.h>
17#include <malloc.h>
18#include <math.h> // fabs
19// #include <memory.h> // memcpy
20
21#include "mypredef.h"
22#include "nrtype.h"
23#include "nrdef.h"
24#include "nrmacro.h"
25#include "nrkernel.h"
26
27/* ------------------------------------------------------------------------------------- */
28IMAGE_EXPORT(void) addcnz_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte  cte, byte **dst)
29/* ------------------------------------------------------------------------------------- */
30{
31        long i,j;
32        byte *Xi, *Yi;
33       
34        for(i=nrl; i<=nrh; i++) {
35                Xi = src[i];
36                Yi = dst[i];
37                for(j=ncl; j<=nch; j++) {
38                        if(Xi[j])
39                                Yi[j] = Xi[j] + cte;
40                        else
41                                Yi[j] = Xi[j];
42                }
43        }
44}
45/* ----------------------------------------------------------------------------------- */
46IMAGE_EXPORT(void) addandc_bmatrix(byte **src,long nrl,long nrh,long ncl, long nch, byte  cte, byte **dst)
47/* ----------------------------------------------------------------------------------- */
48{
49        long i,j;
50        byte *Xi, *Yi;
51       
52        for(i=nrl; i<=nrh; i++) {
53                Xi = src[i];
54                Yi = dst[i];
55                for(j=ncl; j<=nch; j++) {
56                        if(Xi[j])
57                                Yi[j] = Xi[j] + cte;
58                        else
59                                Yi[j] = Xi[i];
60                }
61        }
62}
63/* ---------------------------------------------------------------------------------------- */
64IMAGE_EXPORT(void) addandc_si16matrix(sint16 **src,long nrl,long nrh,long ncl, long nch, short cte, sint16 **dst)
65/* ---------------------------------------------------------------------------------------- */
66{
67        long i,j;
68        sint16 *Xi, *Yi;
69       
70        for(i=nrl; i<=nrh; i++) {
71                Xi = src[i];
72                Yi = dst[i];
73                for(j=ncl; j<=nch; j++) {
74                        if(Xi[j]) Yi[j] = Xi[j] + cte;
75                }
76        }
77}
78/* ------------------------------------------------------------------------------------------- */
79IMAGE_EXPORT(void) addandc_ui16matrix(uint16 **src,long nrl,long nrh,long ncl, long nch, short cte, uint16 **dst)
80/* ------------------------------------------------------------------------------------------ */
81{
82        long i,j;
83        uint16 *Xi, *Yi;
84       
85        for(i=nrl; i<=nrh; i++) {
86                Xi = src[i];
87                Yi = dst[i];
88                for(j=ncl; j<=nch; j++) {
89                        if(Xi[j]) Yi[j] = Xi[j] + cte;
90                }
91        }
92}
93/* ----------------------------------------------------------- */
94IMAGE_EXPORT(int) count_bmatrix(byte **m, long nrl,long nrh,long ncl, long nch)
95/* ----------------------------------------------------------- */
96{
97        long i, j;
98        int s = 0;
99        byte *Xi;
100       
101        for(i=nrl; i<=nrh; i++) {
102                Xi = m[i];
103                for(j=ncl; j<=nch; j++) {
104                        s += Xi[j];
105                }
106    }
107    return s;
108}
Note: See TracBrowser for help on using the repository browser.