<div dir="ltr">Hi All, <div>after several try i was able to perform a good watershed delineation </div><div><br></div><div>wget <a href="https://www.dropbox.com/s/hky66n5ilhpy9k2/impervius_cost.tif">https://www.dropbox.com/s/hky66n5ilhpy9k2/impervius_cost.tif</a></div><div>wget <a href="https://www.dropbox.com/s/vtumfmi9m5i9r4g/markers.tif">https://www.dropbox.com/s/vtumfmi9m5i9r4g/markers.tif</a><br></div><div><br></div><div>python <<EOF</div><div><div>import SimpleITK as sitk</div><div><br></div><div>img = sitk.ReadImage("impervius_cost<wbr>.tif" , sitk.sitkFloat32 ) # 5 '32-bit unsigned integer' # to check img.GetPixelIDTypeAsString() </div><div>core = sitk.ReadImage("markers.tif")</div><div><br></div><div>marker_img = sitk.ConnectedComponent(core, fullyConnected=True)</div><div><br></div><div>ws_line = sitk.MorphologicalWatershedFro<wbr>mMarkers( img, marker_img, markWatershedLine=True, fullyConnected=True)</div><div>ws_poly = sitk.MorphologicalWatershedFro<wbr>mMarkers( img, marker_img, markWatershedLine=False, fullyConnected=True)</div><div><br></div><div>sitk.WriteImage( sitk.Cast( ws_line , sitk.sitkFloat32 ), 'watershed_line.tif' )</div><div>sitk.WriteImage( sitk.Cast( ws_poly , sitk.sitkFloat32 ), 'watershed_poly.tif' )</div><div><br></div></div><div>EOF</div><div><br></div><div>Thanks for the help </div><div>Giuseppe</div><div><br></div><div><img src="cid:ii_15aab97f897b00c2" alt="Inline images 1" width="563" height="296"><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 February 2017 at 17:14, Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Giuseppe,<div><br></div><div>Not all file formats support all pixel types. One approach is to cast the image to a different type. See `help(sitk.Cast)`.</div><div><br></div><div>HTH,</div><div>Matt</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 14, 2017 at 4:11 PM, Giuseppe Amatulli <span dir="ltr"><<a href="mailto:giuseppe.amatulli@gmail.com" target="_blank">giuseppe.amatulli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, <div>thanks for the input. </div><div>I try to follow your suggestion to build up a watershed segmentation image starting from external markers, but i get something strange. </div><div><br></div><div>These are the files that i used </div><div><br></div><div>wget <a href="https://dl.dropboxusercontent.com/u/29337496/small_core.tif" target="_blank">https://dl.dropboxusercontent<wbr>.com/u/29337496/small_core.tif</a></div><div>wget <a href="https://dl.dropboxusercontent.com/u/29337496/cost_Int32.tif" target="_blank">https://dl.dropboxusercontent<wbr>.com/u/29337496/cost_Int32.tif</a><wbr> </div><div><br></div><div>python </div><div><br></div><div><div>import SimpleITK as sitk</div><div><br></div><div>img = sitk.ReadImage("cost_Int32.tif<wbr>")</div><div>core = sitk.ReadImage("small_core.tif<wbr>")</div><div><br></div><div>feature_img = sitk.GradientMagnitude(img)</div><div>marker_img = sitk.ConnectedComponent(core, fullyConnected=False)</div><div><br></div><div>ws = sitk.MorphologicalWatershedFro<wbr>mMarkers(feature_img, marker_img, markWatershedLine=True, fullyConnected=False)</div><div><br></div><div>sitk.WriteImage(ws, 'watershed.jpg' )</div><div><br></div></div><div><br></div><div>Moreover, I also try to save the final image as tiff, but i get the following error. </div><div><br></div><div><div>sitk.WriteImage(ws, 'watershed.tif' )</div><div>Traceback (most recent call last):</div><div> File "<stdin>", line 1, in <module></div><div> File "/usr/local/lib/python2.7/dist<wbr>-packages/SimpleITK/SimpleITK.<wbr>py", line 7942, in WriteImage</div><div> return _SimpleITK.WriteImage(*args)</div><div>RuntimeError: Exception thrown in SimpleITK WriteImage: /tmp/SimpleITK-build/ITK/Modul<wbr>es/IO/TIFF/src/itkTIFFImageIO.<wbr>cxx:544:</div><div>itk::ERROR: TIFFImageIO(0x2e6d880): TIFF supports unsigned/signed char, unsigned/signed short, and float</div></div><div><br></div><div>seams to me the tiff is not supported or i miss some modules of ITK</div><div><br></div><div>May anyone help me </div><div><br></div><div>Thank you </div><div>Best </div><span class="m_822017182400833242HOEnZb"><font color="#888888"><div>Giuseppe </div><div><br></div><div><br></div><div><br></div><div> </div></font></span></div><div class="m_822017182400833242HOEnZb"><div class="m_822017182400833242h5"><div class="gmail_extra"><br><div class="gmail_quote">On 13 February 2017 at 16:15, Francois Budin <span dir="ltr"><<a href="mailto:francois.budin@kitware.com" target="_blank">francois.budin@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hello Giuseppe,<br><br></div>Yes it is possible to create this type of segmentation with ITK.<br></div>The first step would be to convert your RGB(A) image into a grayscale image using RGBToLuminanceImageFilter [1]. The second step would be to run a watershed filter such as MorphologicalWatershedImageFil<wbr>ter [2]. If you want to keep the lines, use "MarkWatershedLineOn()".<br><br></div>Hope this helps,<br></div>Francois<br><div><div><br>[1] <a href="https://itk.org/Doxygen/html/classitk_1_1RGBToLuminanceImageFilter.html" target="_blank">https://itk.org/Doxygen/html/c<wbr>lassitk_1_1RGBToLuminanceImage<wbr>Filter.html</a><br>[2] <a href="https://itk.org/Doxygen/html/classitk_1_1MorphologicalWatershedImageFilter.html" target="_blank">https://itk.org/Doxygen/html/c<wbr>lassitk_1_1MorphologicalWaters<wbr>hedImageFilter.html</a><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Feb 13, 2017 at 3:56 PM, Giuseppe Amatulli <span dir="ltr"><<a href="mailto:giuseppe.amatulli@gmail.com" target="_blank">giuseppe.amatulli@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_822017182400833242m_-6984982706248037708h5"><div dir="ltr"><div><br></div><div>Hi, </div><div>I'm new in <a href="https://itk.org/" target="_blank">ITK</a> and would like to have some directions/suggestions. </div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">I'm trying to segment the image in Figure 1 and be able to identify "valleys" between each one of the blue point. </span></font><span style="font-size:12.8px;color:rgb(0,0,0)">In other words I would like to obtain a red-line on the valleys like the one show in Figure 2. </span></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">Is this possible with ITK and if yes which are the commands/libraries that should use? </span></font></div><div><font color="#000000"><span style="font-size:12.8px">Is there any python-itk example that I can use to obtain something similar. </span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">Thanks </span></font></div><div><font color="#000000"><span style="font-size:12.8px">Best Giuseppe </span></font></div><div><br></div><div><br></div><div>FIGURE 1</div><div><img src="cid:ii_15a3935997cae925" alt="Inline images 2" width="455" height="340"><br></div><div><br></div><div>FIGURE 2</div><div><br></div><div><img src="cid:ii_15a3932c8b533035" alt="Inline images 1" width="256" height="256"><span class="m_822017182400833242m_-6984982706248037708m_-9072125194514460844HOEnZb"><font color="#888888"><br></font></span></div><span class="m_822017182400833242m_-6984982706248037708m_-9072125194514460844HOEnZb"><font color="#888888"><div><br></div><br clear="all"><div><br></div>-- <br><div class="m_822017182400833242m_-6984982706248037708m_-9072125194514460844m_-4908653403124379085gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Giuseppe Amatulli, Ph.D.<br><br>Research scientist at<br><span>Yale School of Forestry & Environmental Studies<br></span><span>Yale Center for Research Computing<br></span>Center for Science and Social Science Information<br>New Haven, 06511<br><div>
Teaching: <a href="http://spatial-ecology.org" target="_blank">http://spatial-ecology.org</a>
</div>
Work: <a href="https://environment.yale.edu/profile/giuseppe-amatulli/" target="_blank">https://environment.yale.edu/p<wbr>rofile/giuseppe-amatulli/</a> <br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</font></span></div>
<br></div></div><span>______________________________<wbr>_________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/community</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_822017182400833242m_-6984982706248037708gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Giuseppe Amatulli, Ph.D.<br><br>Research scientist at<br><span>Yale School of Forestry & Environmental Studies<br></span><span>Yale Center for Research Computing<br></span>Center for Science and Social Science Information<br>New Haven, 06511<br><div>
Teaching: <a href="http://spatial-ecology.org" target="_blank">http://spatial-ecology.org</a>
</div>
Work: <a href="https://environment.yale.edu/profile/giuseppe-amatulli/" target="_blank">https://environment.yale.edu/p<wbr>rofile/giuseppe-amatulli/</a> <br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Giuseppe Amatulli, Ph.D.<br><br>Research scientist at<br><span>Yale School of Forestry & Environmental Studies<br></span><span>Yale Center for Research Computing<br></span>Center for Science and Social Science Information<br>New Haven, 06511<br><div>
Teaching: <a href="http://spatial-ecology.org" target="_blank">http://spatial-ecology.org</a>
</div>
Work: <a href="https://environment.yale.edu/profile/giuseppe-amatulli/" target="_blank">https://environment.yale.edu/profile/giuseppe-amatulli/</a> <br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>