<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://1648/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>So to summarize you would like to do the following:</div><div><br></div><div>1) Estimate a threshold from a histogram and perform thresholding.</div><div>2) Run a "hole filling" algorithm.</div><div><br></div><div>ITK has approximately 13 automatic thresholding algorithms which compute the histogram and estimate the correct threshold.</div><div><br></div><div><a href="http://www.itk.org/Doxygen/html/group__ITKThresholding.html">http://www.itk.org/Doxygen/html/group__ITKThresholding.html</a></div><div><br></div><div>SimpleITK should have all of these methods available, I'd said it's highly likely there is an existing methods which may meet your needs.</div><div><br></div><div>The I believe you are looking for the "BinaryFillhole" filter for the &nbsp;second step, this should also be available in SimpleITK.</div><div><br></div><div><br></div><div>Now, if you don't find any of the existing automatic thresholding algorithms suitable, you have a lot of options on how to implement it.&nbsp;</div><div><br></div><div>If you are working in C# with SimpleITK perhaps it is easiest to just create histogram yourself from the image array ( I am not sure how the image array access is done is C# Dan Mueller may be able to help here) or less efficiently from the GetPixel methods. From there you can compute the threshold and use the BinaryThreshold filter.</div><div><br></div><div>Alternatively, you can go the C++ route and follow how the other automatic threshold filter have done things and create the Calculator and filter class for your method.&nbsp;</div><div><br></div><div>Good Luck,</div><div>Brad</div><div><br></div><div><br><div><div>On Nov 12, 2012, at 2:43 AM, Sebastian Widz &lt;<a href="mailto:widz@infovision.pl">widz@infovision.pl</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="color: rgb(31, 73, 125); ">Dear ITK Team and ITK Users,<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">&nbsp;</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">I am looking for an ITK solution to the following task:<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">&nbsp;</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">For a given T1 weighted MRI Brain Image (Axial plane) create a binary mask that would mark the head region (extract head object from the background)<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">In the past I’ve been doing it by analyzing image histogram, finding the first peak, then finding the first local minimum (m) value with magnitude values greater than the histogram peak.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Pixels with values with magnitude lower or equal (m) were marked with zeros (0), pixels with higher values where marked as ones (1).<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Then some “hole filling” algorithm needs to be applied in order to create a convex shape.<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">&nbsp;</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Can the same be done with ITK filters (possibly SimpleITK as I use the C# Managed version)?<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Maybe there are some other ways you would suggest, as my way not always gives expected .<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">&nbsp;</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Best Regards,<o:p></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Sebastian<o:p></o:p></span></div></div>_____________________________________<br>Powered by<span class="Apple-converted-space">&nbsp;</span><a href="http://www.kitware.com" style="color: purple; text-decoration: underline; ">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" style="color: purple; text-decoration: underline; ">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php" style="color: purple; text-decoration: underline; ">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br><a href="http://www.itk.org/Wiki/ITK_FAQ" style="color: purple; text-decoration: underline; ">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-users" style="color: purple; text-decoration: underline; ">http://www.itk.org/mailman/listinfo/insight-users</a><br></div></blockquote></div><br></div></body></html>