<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Matt,<div><br></div><div>You are right, the vtk format is always 3D. If you have a 2D image and save it as vtk, then the writer automatically add the last dimension with a spacing 1. </div><div>For example, this is the 2D image create with the python code:</div><div><br></div><div><div>ariel@Gohan:~/Uva/LPI/Proyectos/Python-ITK-VTK-QT/Ultrasonido/SpeckleTracking$ head -10 img.vtk </div><div># vtk DataFile Version 3.0</div><div>VTK File Generated by Insight Segmentation and Registration Toolkit (ITK)</div><div>BINARY</div><div>DATASET STRUCTURED_POINTS</div><div>DIMENSIONS 100 100 1 </div><div>SPACING 1.0000000000000000e+00 1.0000000000000000e+00 1.0000000000000000e+00 </div><div>ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 </div><div>POINT_DATA 10000</div><div>SCALARS scalars double 1</div><div>LOOKUP_TABLE default</div></div><div>.....</div><div><br></div><div>I don't know why the warning say that the spacing must be grater than 0</div><div><br></div><div>Ps: I can read this image using vtk. </div><div><br></div><div>Thanks for your quickly response.</div><div><br><div apple-content-edited="true">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-style: normal; font-weight: normal; font-size: medium; font-family: Helvetica; color: rgb(0, 0, 0); "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: 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-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">Cheers,</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">__________________________________<br><font class="Apple-style-span" color="#b7bfc5">|</font> Ariel Hernán Curiale Ph.D Student<br><font class="Apple-style-span" color="#b7bfc5">|</font> ETSI Telecomunicación<br><font class="Apple-style-span" color="#b7bfc5">|</font> Universidad de Valladolid<br><font class="Apple-style-span" color="#b7bfc5">|</font> Campus Miguel Delibes<br><font class="Apple-style-span" color="#b7bfc5">|</font> 47011 Valladolid, Spain<br><font class="Apple-style-span" color="#b7bfc5">|</font> Phone: 983-423000 ext. 5590</div><div><font class="Apple-style-span" color="#b7b7b7" style="font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">|</font> Web: <a href="http://www.curiale.com.ar/"><font class="Apple-style-span" color="#084ebe">www.curiale.com.ar</font></a><br><font class="Apple-style-span" color="#b7b7b7" style="font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">|</font><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; color: rgb(0, 0, 0); ">_________________________________</span></div></div></div></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div>
</div>
<br><div><div>El 06/08/2013, a las 17:52, Matt McCormick escribió:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi Ariel,<br><br>The VTK file format [1] is always 3D, so a non-zero spacing will need<br>to be specified if using this format.<br><br>HTH,<br>Matt<br><br>[1] <a href="http://www.vtk.org/VTK/img/file-formats.pdf">www.vtk.org/VTK/img/file-formats.pdf</a><br><br><br>On Tue, Aug 6, 2013 at 3:00 PM, Ariel Hernán Curiale <<a href="mailto:curiale@gmail.com">curiale@gmail.com</a>> wrote:<br><blockquote type="cite">Hi,<br></blockquote><blockquote type="cite">I create a simple example to show you the problem that I'm getting when I'm<br></blockquote><blockquote type="cite">trying to read a vtk file. I'm using the last release of SimpleITK<br></blockquote><blockquote type="cite">(SimpleITK-0.6.1) and python.<br></blockquote><blockquote type="cite">In this example, I create, write and read a simple image.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Here is the code:<br></blockquote><blockquote type="cite">-------------------------<br></blockquote><blockquote type="cite">import SimpleITK as sitk<br></blockquote><blockquote type="cite">import scipy as sc<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">dim = (100, 100)<br></blockquote><blockquote type="cite">origin = (0, 0)<br></blockquote><blockquote type="cite">spacing = (0.834496, 0.8223519)<br></blockquote><blockquote type="cite">img = sc.zeros(dim)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">img[20:40, 20:40] = 1<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">img_sitk = sitk.GetImageFromArray(img)<br></blockquote><blockquote type="cite">img_sitk.SetOrigin(origin)<br></blockquote><blockquote type="cite">img_sitk.SetSpacing(spacing)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">print img_sitk<br></blockquote><blockquote type="cite">sitk.Show(img_sitk)<br></blockquote><blockquote type="cite">sitk.WriteImage(img_sitk,"img.vtk")<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">im = sitk.ReadImage("img.vtk")<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">reader = sitk.ImageFileReader()<br></blockquote><blockquote type="cite">reader.SetFileName("img.vtk")<br></blockquote><blockquote type="cite">im2 = reader.Execute()<br></blockquote><blockquote type="cite">--------<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The img_sitk seems to be created properly:<br></blockquote><blockquote type="cite">----<br></blockquote><blockquote type="cite">Image (0x7f9a95ff8550)<br></blockquote><blockquote type="cite"> RTTI typeinfo: itk::Image<double, 2u><br></blockquote><blockquote type="cite"> Reference Count: 1<br></blockquote><blockquote type="cite"> Modified Time: 3295<br></blockquote><blockquote type="cite"> Debug: Off<br></blockquote><blockquote type="cite"> Observers:<br></blockquote><blockquote type="cite"> none<br></blockquote><blockquote type="cite"> Source: (none)<br></blockquote><blockquote type="cite"> Source output name: (none)<br></blockquote><blockquote type="cite"> Release Data: Off<br></blockquote><blockquote type="cite"> Data Released: False<br></blockquote><blockquote type="cite"> Global Release Data: Off<br></blockquote><blockquote type="cite"> PipelineMTime: 0<br></blockquote><blockquote type="cite"> UpdateMTime: 0<br></blockquote><blockquote type="cite"> RealTimeStamp: 0 seconds<br></blockquote><blockquote type="cite"> LargestPossibleRegion:<br></blockquote><blockquote type="cite"> Dimension: 2<br></blockquote><blockquote type="cite"> Index: [0, 0]<br></blockquote><blockquote type="cite"> Size: [100, 100]<br></blockquote><blockquote type="cite"> BufferedRegion:<br></blockquote><blockquote type="cite"> Dimension: 2<br></blockquote><blockquote type="cite"> Index: [0, 0]<br></blockquote><blockquote type="cite"> Size: [100, 100]<br></blockquote><blockquote type="cite"> RequestedRegion:<br></blockquote><blockquote type="cite"> Dimension: 2<br></blockquote><blockquote type="cite"> Index: [0, 0]<br></blockquote><blockquote type="cite"> Size: [100, 100]<br></blockquote><blockquote type="cite"> Spacing: [0.834496, 0.822352]<br></blockquote><blockquote type="cite"> Origin: [0, 0]<br></blockquote><blockquote type="cite"> Direction:<br></blockquote><blockquote type="cite">1 0<br></blockquote><blockquote type="cite">0 1<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> IndexToPointMatrix:<br></blockquote><blockquote type="cite">0.834496 0<br></blockquote><blockquote type="cite">0 0.822352<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> PointToIndexMatrix:<br></blockquote><blockquote type="cite">1.19833 0<br></blockquote><blockquote type="cite">0 1.21602<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> Inverse Direction:<br></blockquote><blockquote type="cite">1 0<br></blockquote><blockquote type="cite">0 1<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> PixelContainer:<br></blockquote><blockquote type="cite"> ImportImageContainer (0x7f9a960309b0)<br></blockquote><blockquote type="cite"> RTTI typeinfo: itk::ImportImageContainer<unsigned long, double><br></blockquote><blockquote type="cite"> Reference Count: 1<br></blockquote><blockquote type="cite"> Modified Time: 2866<br></blockquote><blockquote type="cite"> Debug: Off<br></blockquote><blockquote type="cite"> Observers:<br></blockquote><blockquote type="cite"> none<br></blockquote><blockquote type="cite"> Pointer: 0x7f9a95352200<br></blockquote><blockquote type="cite"> Container manages memory: true<br></blockquote><blockquote type="cite"> Size: 10000<br></blockquote><blockquote type="cite"> Capacity: 10000<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">But when I try to read the image using sitk.ReadImage or<br></blockquote><blockquote type="cite">sitk.ImageFileReader I'm getting this error:<br></blockquote><blockquote type="cite">----<br></blockquote><blockquote type="cite">Traceback (most recent call last):<br></blockquote><blockquote type="cite"> File "<stdin>", line 1, in <module><br></blockquote><blockquote type="cite"> File<br></blockquote><blockquote type="cite">"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SimpleITK-0.6.1_g1387a-py2.7-macosx-10.7-x86_64.egg/SimpleITK.py",<br></blockquote><blockquote type="cite">line 4371, in Execute<br></blockquote><blockquote type="cite"> return _SimpleITK.ImageFileReader_Execute(self)<br></blockquote><blockquote type="cite">RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute:<br></blockquote><blockquote type="cite">/Users/ariel/Applications/InsightToolkit-4.4.0/Modules/Core/Common/include/itkImageBase.hxx:189:<br></blockquote><blockquote type="cite">itk::ERROR: Image(0x7f9a95d9d640): A spacing of 0 is not allowed: Spacing is<br></blockquote><blockquote type="cite">[1, 0]<br></blockquote><blockquote type="cite">----<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">It seems to be a bug but, I don't know if I'm doing something wrong.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Cheers,<br></blockquote><blockquote type="cite">__________________________________<br></blockquote><blockquote type="cite">| Ariel Hernán Curiale Ph.D Student<br></blockquote><blockquote type="cite">| ETSI Telecomunicación<br></blockquote><blockquote type="cite">| Universidad de Valladolid<br></blockquote><blockquote type="cite">| Campus Miguel Delibes<br></blockquote><blockquote type="cite">| 47011 Valladolid, Spain<br></blockquote><blockquote type="cite">| Phone: 983-423000 ext. 5590<br></blockquote><blockquote type="cite">| Web: <a href="http://www.curiale.com.ar">www.curiale.com.ar</a><br></blockquote><blockquote type="cite">|_________________________________<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_____________________________________<br></blockquote><blockquote type="cite">Powered by <a href="http://www.kitware.com">www.kitware.com</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Visit other Kitware open-source projects at<br></blockquote><blockquote type="cite"><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Kitware offers ITK Training Courses, for more information visit:<br></blockquote><blockquote type="cite"><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Please keep messages on-topic and check the ITK FAQ at:<br></blockquote><blockquote type="cite"><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Follow this link to subscribe/unsubscribe:<br></blockquote><blockquote type="cite"><a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br></div></body></html>