-
Notifications
You must be signed in to change notification settings - Fork 1
/
dmag5_downsample_rgb_image_int.c
71 lines (57 loc) · 1.18 KB
/
dmag5_downsample_rgb_image_int.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "header.h"
#include "proto.h"
void dmag5_downsample_rgb_image_int(
int *inp_I_rgb_int,
int inp_xdim,
int inp_ydim,
int *out_I_rgb_int,
int out_xdim,
int out_ydim,
double factor
)
/*
The output image must be allocated outside the function
*/
{
int inp_size;
int out_size;
int *inp_I_int;
int *out_I_int;
int cind;
int i;
int j;
int pixel;
inp_size= inp_xdim*inp_ydim;
out_size= out_xdim*out_ydim;
if ( inp_size > 0 )
inp_I_int= (int *)calloc(inp_size,sizeof(int));
if ( out_size > 0 )
out_I_int= (int *)calloc(out_size,sizeof(int));
for ( cind= 0 ; cind< 3 ; cind++ ) {
for ( i= 0 ; i< inp_ydim ; i++ ) {
for ( j= 0 ; j< inp_xdim ; j++ ) {
pixel= i*inp_xdim+j;
inp_I_int[pixel]= inp_I_rgb_int[3*pixel+cind];
}
}
dmag5_downsample_image_int(
inp_I_int,
inp_xdim,
inp_ydim,
out_I_int,
out_xdim,
out_ydim,
factor
);
for ( i= 0 ; i< out_ydim ; i++ ) {
for ( j= 0 ; j< out_xdim ; j++ ) {
pixel= i*out_xdim+j;
out_I_rgb_int[3*pixel+cind]= out_I_int[pixel];
}
}
}
if ( inp_size > 0 )
free(inp_I_int);
if ( out_size > 0 )
free(out_I_int);
}