Here there,
I'm currently working on a C# project and I need to create a snippet using SimpleITK libraries, in which my image matrix ArrayIn will be compared to a number DoubleVar.
Then, if, for each element, the value of ArrayIn is greater than the DoubleVar one, the respective element of my output image ArrayOut will be 1. If not, that element will be 0. The matrix ArrayOut is a binary Image , with ones and zeros. The size of AArrayOut will be the same as the input's one. I need to use the function Getbufferasint16() but I can't do so.
The following code is part of intents , but with no result
uint8_t *buffer = (my image) ->GetBufferAsUInt16();
buffer[c + numComponents*(x+ xSize* (y*+ySize*z))];
Please find this new example on how to access a buffer from SimpleITK in C#: http://www.itk.org/SimpleITKDoxygen/html/ImageGetBuffer_8cs-example.html
You need to you need to use the Marshal class to safely interface the unmanaged code with the C# data, or use an unsafe block: