[ITK] [ITK-users] Strange coordinates output by itk::ContourExtractor2DImageFilter

沈庄明 zhuangming.shen at sphic.org.cn
Tue Mar 15 20:45:56 EDT 2016


Hi Dženan,


Thank you for your prompt response. I found I made a mistake in my code. It works correctly now. Thanks again.


Regards,

Zhuangming Shen


________________________________
From: Dženan Zukić <dzenanz at gmail.com>
Sent: Wednesday, March 16, 2016 2:41 AM
To: 沈庄明
Cc: insight-users at itk.org
Subject: Re: [ITK-users] Strange coordinates output by itk::ContourExtractor2DImageFilter

Hi Shen,

using a recent version of ITK<https://github.com/InsightSoftwareConsortium/ITK/commit/90b04fba49007c300caba06f796fff6976424c40> (and using the attached C++ version of your code) I could not reproduce this problem. For me the output is:
[197, 378]
[196, 378]
[195, 379]
[194, 379]
[193, 379]
[192, 380]
[191, 380]
[190, 380]
[189, 380]
[188, 380]
[187, 381]

Regards,
Dženan

On Mon, Mar 14, 2016 at 11:00 PM, 沈庄明 <zhuangming.shen at sphic.org.cn<mailto:zhuangming.shen at sphic.org.cn>> wrote:

Hi all,


I used itk::ContourExtractor2DImageFilter to extract contours from a binary image (i.e. only 0 or 255 for pixel intensity). Mostly, the code can work correctly. However, the code sometimes outputs very strange coordinates (e.g. (194.0, 5.36011819173e-320) ), which should represent the path of the contour. When I change the contour value from 0 to other number no less than 255 (i.e. 250), I got more strange coordinates. My code and results are listed as below. Has anyone met the same situation?​



Regards,


Zhuangming Shen




Here is my code

=======================================================================================

import itk

reader = itk.ImageFileReader[itk.Image.UC2].New()
reader.SetFileName("test.nii")
reader.Update()

contour_extractor = itk.ContourExtractor2DImageFilter[itk.Image.UC2].New()
contour_extractor.SetInput(reader.GetOutput())
contour_extractor.SetContourValue(0)
contour_extractor.Update()

contour_number = contour_extractor.GetNumberOfOutputs()

print("There are "+str(contour_number)+" contours")

for k in xrange(contour_number):
    print("================  Contour "+str(k)+" ================")

    point_number = contour_extractor.GetOutput(k).GetVertexList().Size()
    print("Point number: "+str(point_number))

    for i in xrange(point_number):
        print("("+str(contour_extractor.GetOutput(k).GetVertexList().GetElement(i)[0])+","+str(contour_extractor.GetOutput(0).GetVertexList().GetElement(i)[1])+")")




Here is my results

=========================================================================================

There are 2 contours
================  Contour 0 ================
Point number: 670
(373.0,380.0)
(372.0,380.0)
(371.0,380.0)
(370.0,380.0)
(369.0,380.0)
(368.0,380.0)
(367.0,380.0)
...
(375.0,379.0)
(374.0,379.0)
(373.0,380.0)
================  Contour 1 ================
Point number: 677
(188.0,380.0)
(187.0,380.0)
(186.0,380.0)
(185.0,380.0)
...
(198.0,379.0)
(197.0,379.0)
(196.0,379.0)
(195.0,380.0)
(194.0,5.36011819173e-320)
(193.0,382.0)
(192.0,382.0)
(191.0,382.0)
(190.0,382.0)
(189.0,382.0)
(188.0,382.0)




Here is the input test.nii
=============================================================================================
[cid:beaa107f-9827-40b6-aac6-cdb30092e744]​


_____________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160316/9a50e250/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 8798 bytes
Desc: pastedImage.png
URL: <http://public.kitware.com/pipermail/community/attachments/20160316/9a50e250/attachment-0001.png>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list