using System;
using System.Runtime.InteropServices;
namespace itk.simple.examples {
public class Program {
static void Main(string[] args) {
if (args.Length < 1) {
Console.WriteLine("Usage: SimpleGaussian <input>");
return;
}
input = SimpleITK.Cast(input, PixelId.sitkFloat32);
VectorUInt32 size = input.
GetSize();
int len = 1;
for (int dim = 0; dim < input.GetDimension(); dim++) {
len *= (int)size[dim];
}
IntPtr buffer = input.GetBufferAsFloat();
float[] bufferAsArray = new float[len];
Marshal.Copy(buffer, bufferAsArray, 0, len);
double total = 0.0;
for (int j = 0; j < size[1]; j++) {
for (int i = 0; i < size[0]; i++) {
float pixel = bufferAsArray[i + j*size[1]];
total += pixel;
}
}
Console.WriteLine("Pixel value total: {0}", total);
}
}
}