<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,sans-serif">Hi Matthias,</span><br style="font-family:arial,sans-serif"><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">To import the 2d array into SimpleITK you can use the ImportAsXXX function. You need to make sure you match your pixel types correctly (e.g. if your buffer is float, using ImportAsFloat, etc).</span><br style="font-family:arial,sans-serif"><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">Here is some C# code that might help you.</span><br style="font-family:arial,sans-serif"><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">using System;</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">using System.Runtime.InteropServices;</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">using sitk = itk.simple.SimpleITK;</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">using simple = itk.simple;</span><br style="font-family:arial,sans-serif"><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">namespace itk.simple {</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">public class ImageProcessing {</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">    public static void Main(string[] args) {</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">        try {</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            var size = new simple.VectorUInt32(2) { 256, 256 };</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            var spacing = new simple.VectorDouble(2) { 1.0, 1.0 };</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            var buffer = new float[size[0] * size[1]];</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            GCHandle bufferPinned = GCHandle.Alloc(buffer, GCHandleType.Pinned); // Pin managed array</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            IntPtr bufferPtr = bufferPinned.AddrOfPinnedObject(); // Get address of array</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            // Import buffer as SimpleITK image</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            var input = sitk.ImportAsFloat(bufferPtr, size, spacing);</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            // Compute regional maxima</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            var maxima = sitk.RegionalMaxima(input, backgroundValue: 0, foregroundValue: 255, fullyConnected: true);</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            sitk.WriteImage(maxima, @"C:\Temp\maxima.mha");</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            bufferPinned.Free(); // Free pinned array</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">        } catch (Exception ex) {</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">            Console.WriteLine(ex);</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">        }</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">    }</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">}</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">}</span><br style="font-family:arial,sans-serif"><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">Hope this helps.</span><br style="font-family:arial,sans-serif"><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">Cheers, Dan</span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 August 2016 at 09:22, Matthias B <span dir="ltr"><<a href="mailto:matthias.b@hotmail.com" target="_blank">matthias.b@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">Hey,<div><br></div><div>I'm programming in VB.Net, I succesfully added the ITK managed C# library wrapper to my VS project.<br>Now I'm able to use the ITK C# functions in VB.Net.</div><div><br></div><div>My goal is to use a regional maxima filter (ITK) on a 2D-array that I declared in VB.Net<br><br>I have really no idea how to do this and if this is even possible.</div><div><br></div><div>Hope somebody can help me with this.<br><br>Thank you, Matthias</div><div><br> <table style="border-top:1px solid #d3d4de">
        <tbody><tr>
      <td style="width:55px;padding-top:18px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/2016/icons/icon-envelope-tick-round-orange_184x116-v1.png" width="46" height="29" style="width:46px;min-height:29px"></a></td>
                <td style="width:470px;padding-top:17px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virusvrij. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:#4453ea" target="_blank">www.avast.com</a>            </td>
        </tr>
</tbody></table>
<a href="#m_-7220795038837665703_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>                                    </div></div>
<br>______________________________<wbr>_________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/community</a><br>
<br></blockquote></div><br></div>