GRASS 8 Programmer's Manual
8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
c_intr.c
Go to the documentation of this file.
1
#include <
grass/gis.h
>
2
#include <
grass/raster.h
>
3
#include <
grass/stats.h
>
4
5
void
c_intr
(
DCELL
*result,
DCELL
*values,
int
n,
const
void
*closure
UNUSED
)
6
{
7
DCELL
center
;
8
int
count
;
9
int
diff
;
10
int
i;
11
12
if
(
Rast_is_d_null_value
(&values[n / 2])) {
13
Rast_set_d_null_value
(result, 1);
14
return
;
15
}
16
17
center
= values[n / 2];
18
count
= 0;
19
diff
= 0;
20
21
for
(i = 0; i < n; i++) {
22
if
(
Rast_is_d_null_value
(&values[i]))
23
continue
;
24
25
count
++;
26
if
(values[i] !=
center
)
27
diff
++;
28
}
29
30
count
--;
31
32
if
(
count
<= 0)
33
*result = 0;
34
else
35
*result = (
diff
* 100.0 + (
count
/ 2)) /
count
+ 1;
36
}
AMI_STREAM
Definition
ami_stream.h:153
Rast_set_d_null_value
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
Definition
null_val.c:153
Rast_is_d_null_value
#define Rast_is_d_null_value(dcellVal)
Definition
defs/raster.h:417
c_intr
stat_func c_intr
gis.h
DCELL
double DCELL
Definition
gis.h:635
UNUSED
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition
gis.h:46
count
int count
raster.h
stats.h
lib
stats
c_intr.c
Generated on Fri Apr 3 2026 06:59:56 for GRASS 8 Programmer's Manual by
1.9.8