ubyte[] data =
[
2, 1, 3, 5, 2,
9, 1, 2, 6, 3,
2, 5, 2, 9, 1,
8, 3, 6, 3, 0,
6, 2, 8, 1, 5
];
ubyte[] datav1 =
[
1, 2, 6, 3, 0, 0, 0,
5, 2, 9, 1, 0, 0, 0,
3, 6, 3, 0, 0, 0, 0,
2, 8, 1, 5, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
];
ubyte[] datav2 =
[
0, 0, 0, 0, 0, 0, 0,
0, 2, 1, 3, 5, 2, 0,
0, 9, 1, 2, 6, 3, 0,
0, 2, 5, 2, 9, 1, 0,
0, 8, 3, 6, 3, 0, 0,
0, 6, 2, 8, 1, 5, 0,
0, 0, 0, 0, 0, 0, 0
];
auto orig = Image2( ivec2( 7, 7 ), ElemInfo( DataType.UBYTE, 1 ) );
auto im = Image2( ivec2( 5, 5 ), DataType.UBYTE, 1, data );
auto res = Image2(orig);
imPaste( res, ivec2(-1,-1), im );
assert( res.data == datav1 );
res = Image2(orig);
imPaste( res, ivec2(1,1), im );
assert( res.data == datav2 );
ubyte[] src_data =
[
1,2,3,
4,5,6,
7,8,9
];
ubyte[] dst1_data =
[
0,0,0,
0,0,0,
0,0,0,
1,2,3,
4,5,6,
7,8,9,
0,0,0,
0,0,0,
0,0,0
];
ubyte[] dst2_data =
[
0,1,0,
0,2,0,
0,3,0,
0,4,0,
0,5,0,
0,6,0,
0,7,0,
0,8,0,
0,9,0
];
auto src = Image2( ivec2(3,3), ElemInfo( DataType.UBYTE, 1 ), src_data );
auto dst = Image3( ivec3(3,3,3), ElemInfo( DataType.UBYTE, 1 ) );
imPaste( dst, ivec3(0,0,1), Image3( src ) );
assert( dst.data == dst1_data );
dst.clear();
imPaste( dst, ivec3(1,0,0), Image3(src,0) );
assert( dst.data == dst2_data );
1 ubyte[] dt =
2 [
3 0,0,0,0,
4 0,0,0,0,
5 0,0,0,0,
6 0,0,0,0,
7
8 0,0,0,0,
9 0,1,2,0,
10 0,3,4,0,
11 0,0,0,0,
12
13 0,0,0,0,
14 0,5,6,0,
15 0,7,8,0,
16 0,0,0,0,
17
18 0,0,0,0,
19 0,0,0,0,
20 0,0,0,0,
21 0,0,0,0
22 ];
23
24 ubyte[] cp =
25 [
26 1,2,1,2,
27 3,4,3,4,
28 1,2,1,2,
29 3,4,3,4,
30
31 5,6,5,6,
32 7,8,7,8,
33 5,6,5,6,
34 7,8,7,8,
35
36 1,2,1,2,
37 3,4,3,4,
38 1,2,1,2,
39 3,4,3,4,
40
41 5,6,5,6,
42 7,8,7,8,
43 5,6,5,6,
44 7,8,7,8,
45 ];
46
47 ubyte[] rs =
48 [
49 8,7,
50 6,5,
51 4,3,
52 2,1
53 ];
54
55 ubyte[] nnd = [ 0,0, 0,0, 0,0, 0,8 ];
56
57 auto a = Image3( [4,4,4], ElemInfo( DataType.UBYTE, 1 ), dt );
58 auto b = Image3( [4,4,4], ElemInfo( DataType.UBYTE, 1 ), cp );
59 auto c = Image3( [4,4,4], ElemInfo( DataType.UBYTE, 1 ) );
60
61 auto part = imCopy( a, iRegion3( ivec3(1,1,1), ivec3(2,2,2) ) );
62
63 imPaste( c, ivec3(0,0,0), part );
64 imPaste( c, ivec3(0,2,0), part );
65 imPaste( c, ivec3(2,0,0), part );
66 imPaste( c, ivec3(2,2,0), part );
67
68 imPaste( c, ivec3(0,0,2), part );
69 imPaste( c, ivec3(0,2,2), part );
70 imPaste( c, ivec3(2,0,2), part );
71 imPaste( c, ivec3(2,2,2), part );
72
73 assert( b == c );
74
75 auto part2 = imCopy( b, iRegion3(ivec3(1,1,1), ivec3(2,2,2)) );
76 auto rr = Image3( ivec3(2,2,2), ElemInfo( DataType.UBYTE, 1 ), rs );
77 assert( rr == part2 );
78
79 auto nn = imCopy( rr, iRegion3( ivec3(-1,-1,-1), ivec3(2,2,2) ) );
80 auto nndi = Image3( ivec3(2,2,2), ElemInfo( DataType.UBYTE,1 ), nnd );
81
82 assert( nn == nndi );
paste in image other image