-
Notifications
You must be signed in to change notification settings - Fork 2
/
IArrayHandler.cs
100 lines (98 loc) · 4.7 KB
/
IArrayHandler.cs
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
/*
* Vision.NET 2.1 Computer Vision Library
* Copyright (C) 2009 Matthew Johnson
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace VisionNET
{
/// <summary>
/// Interface defining an array handler. This is a class which is provides several methods for handling large three-dimensional arrays which are
/// useful for computer vision.
/// </summary>
/// <typeparam name="T">Any type, though ideally one on which arithmetic operators are defined.</typeparam>
public interface IArrayHandler<T>
{
/// <summary>
/// Number of rows in the array.
/// </summary>
int Rows { get; }
/// <summary>
/// Number of columns in the array.
/// </summary>
int Columns { get; }
/// <summary>
/// Number of channels in the array.
/// </summary>
int Channels { get; }
/// <summary>
/// Clears all data from the array.
/// </summary>
void Clear();
/// <summary>
/// Sets the data of the array to <paramref name="data"/>. This new array will replace the current one. No copy is created.
/// </summary>
/// <param name="data">Array to handle</param>
void SetData(T[, ,] data);
/// <summary>
/// Sets the dimensions of the underlying array. The resulting new array will replace the old array completely, no data will be copied over.
/// </summary>
/// <param name="rows">Number of desired rows in the new array.</param>
/// <param name="columns">Number of desired columns in the new array.</param>
/// <param name="channels">Number of desired channels in the new array.</param>
void SetDimensions(int rows, int columns, int channels);
/// <summary>
/// Sets whether this array is an integral array. This property influences how the rectangle sum will be computed.
/// </summary>
bool IsIntegral { get; set; }
/// <summary>
/// Computes a sum of the values in the array within the rectangle starting at (<paramref name="startRow" />, <paramref name="startColumn"/>) in <paramref name="channel"/>
/// with a size of <paramref name="rows"/>x<paramref name="columns"/>.
/// </summary>
/// <param name="startRow">Starting row</param>
/// <param name="startColumn">Starting column</param>
/// <param name="rows">Number of rows in the rectangle</param>
/// <param name="columns">Number of columns in the rectangle</param>
/// <param name="channel">Channel to draw values from</param>
/// <returns>The sum of all values in the rectangle</returns>
T ComputeRectangleSum(int startRow, int startColumn, int rows, int columns, int channel);
/// <summary>
/// Extracts an entire channel from the array.
/// </summary>
/// <param name="channel">Channel to extract</param>
/// <returns>Extracted channel</returns>
T[,] ExtractChannel(int channel);
/// <summary>
/// Extracts a portion of the array defined by the parameters.
/// </summary>
/// <param name="startRow">Starting row</param>
/// <param name="startColumn">Starting column</param>
/// <param name="rows">Number of rows in the portion</param>
/// <param name="columns">Number of columns in the portion</param>
/// <returns>A portion of the array</returns>
T[, ,] ExtractRectangle(int startRow, int startColumn, int rows, int columns);
/// <summary>
/// The underlying array. Breaks capsulation to allow operations using pointer arithmetic.
/// </summary>
T[, ,] RawArray { get; }
/// <summary>
/// Indexes the underlying array.
/// </summary>
/// <param name="row">Desired row</param>
/// <param name="column">Desired column</param>
/// <param name="channel">Desired column</param>
/// <returns>Value at (<paramref name="row"/>, <paramref name="column"/>, <paramref name="channel"/>) within the array.</returns>
T this[int row, int column, int channel] { get; set; }
}
}