void pyramid Node node Image image node- image int max image width ima

 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
void pyramid(Node * node)
{
Image image = node->image;
int N = max(image.width,image.height);
if (N > 2)
{
int width = image.width / 2;
int height = image.height / 2;
node->min = new Node(width / 2, height /2);
node->max = new Node(width / 2, height /2);
node->middle = new Node(width / 2, height /2);
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
{
node->min.image[i,j] = min(image[i * 2, j * 2],image[i * 2 + 1, j * 2],image[i * 2, j * 2 + 1],image[i * 2 + 1, j * 2 + 1]);
node->max.image[i,j] = max(image[i * 2, j * 2],image[i * 2 + 1, j * 2],image[i * 2, j * 2 + 1],image[i * 2 + 1, j * 2 + 1]);
node->middle.image[i,j] = (image[i * 2, j * 2]+image[i * 2 + 1, j * 2]+image[i * 2, j * 2 + 1]+image[i * 2 + 1, j * 2 + 1]) / 4;
}
pyramid(node->min);
pyramid(node->max);
pyramid(node->middle);
}
return;
}