-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectors.h
103 lines (93 loc) · 2.97 KB
/
selectors.h
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "Image.h"
class Selectors
{
public:
template<BaseType, 2, SampleDimension>
static void getSubImage (
Image<BaseType, 2, SampleDimension>& sourceImage,
Image<BaseType, 2, SampleDimension>& destinationImage,
unsigned int xmin,
unsigned int ymin,
unsigned int xmax,
unsigned int ymax)
{
const unsigned int dw = (xmax-xmin);
const unsigned int dh = (ymax-ymin);
const unsigned int sw = sourceImage.getSize (sourceImage.WIDTH);
const unsigned int sh = sourceImage.getSize (sourceImage.HEIGHT);
unsigned int x, y, sidx;
Sample& smpl;
Sample& dmpl;
// Image<BaseType, ImageDimension, SampleDimension> *subImage = new Image<BaseType, ImageDimension, SampleDimension> (sampleCount);
destinationImage.setSampleCount (dw*dh);
destinationImage.setSize (destinationImage.WIDTH, dw);
destinationImage.setSize (destinationImage.HEIGHT, dh);
// copy the data over
for (y=ymin; y<ymax; y++)
{
for (x=xmin; x<xmax; x++)
{
sidx = (y*sw)+x;
didx = ((y-ymin)*dw)+(x-xmin);
smpl = sourceImage.getSample (sidx);
dmpl = destinationImage.getSample (didx);
dmpl.set (&smpl.v);
}
}
}
template<BaseType, 3, SampleDimension>
static void getSpatialPlane (
Image<BaseType, 3, SampleDimension>& sourceImage,
Image<BaseType, 2, SampleDimension>& destinationImage,
const Image<BaseType, 3, SampleDimensions>::Dimensions targetDimension,
const unsigned int planeIndex)
{
unsigned int dw = (xmax-xmin);
unsigned int dh = (ymax-ymin);
unsigned int sw = sourceImage.getSize (sourceImage.WIDTH);
unsigned int sh = sourceImage.getSize (sourceImage.HEIGHT);
unsigned int x, y, z, i, sidx;
Sample& smpl;
Sample& dmpl;
switch (targetDimension)
{
case sourceImage.WIDTH:
{
sw = sourceImage.getSize (sourceImage.HEIGHT);
sh = sourceImage.getSize (sourceImage.DEPTH);
break;
}
case sourceImage.HEIGHT:
{
sw = sourceImage.getSize (sourceImage.WIDTH);
sh = sourceImage.getSize (sourceImage.DEPTH);
break;
}
case sourceImage.DEPTH:
{
sw = sourceImage.getSize (sourceImage.WIDTH);
sh = sourceImage.getSize (sourceImage.HEIGHT);
break;
}
default:
return;
}
destinationImage.setSampleCount (sw*sh);
destinationImage.setSize (destinationImage.WIDTH, sw);
destinationImage.setSize (destinationImage.HEIGHT, sh);
switch (targetDimension)
{
case sourceImage.WIDTH:
{
for (z=0; z<sourceImage.getSize (sourceImage.DEPTH); z++)
{
for (y=0; y<sourceImage.getSize (sourceImage.HEIGHT); y++)
{
// for (x=0; x<sourceImage.getSize (sourceImage.WIDTH); x++)
{
}
}
}
}
}
}