[ITK-users] ScalarImageToTextureFeaturesFilter

Zou Jing <[email protected]> Mon, 25 Jun 2018 03:27:37 +0000
Newsgroups gmane.comp.lib.itk.user
Message-ID <BL2PR06MB22921BBDAF860FC3FC8433CAA84A0@BL2PR06MB2292.namprd06.prod.outlook.com>
--===============1640266504==
Content-Language: zh-CN
Content-Type: multipart/alternative;
	boundary="_000_BL2PR06MB22921BBDAF860FC3FC8433CAA84A0BL2PR06MB2292namp_"

--_000_BL2PR06MB22921BBDAF860FC3FC8433CAA84A0BL2PR06MB2292namp_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable


Dear all,

I am new to ITK and  I want to calculate texture features of  NIFTI images.
But the result of different images are all the same, the result are 1 0 1 0=
 0 0
I=92d appreciate it if you could help me .
Many thanks.

Here attached the code :

#include "itkImage.h"
#include "itkScalarImageToTextureFeaturesFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkNiftiImageIO.h"


typedef itk::Image<float, 3> ImageType;


int main()
{
         typedef itk::ImageFileReader<ImageType>ReaderType;
         ReaderType::Pointer reader =3D ReaderType::New();
         ReaderType::Pointer reader1 =3D ReaderType::New();


         reader->SetFileName("C:/Users/studentx/Downloads/lung_data/NormalL=
ung2/F63y/F63_2013.nii");
         reader->Update();

         reader1->SetFileName("C:/Users/studentx/Downloads/lung_data/Normal=
Lung2/F63y/F63_2013_mask.nii");
         reader1->Update();


         typedef itk::Statistics::ScalarImageToTextureFeaturesFilter<ImageT=
ype> TextureFilterType;
         TextureFilterType::Pointer textureFilter =3D TextureFilterType::Ne=
w();
         textureFilter->SetInput(reader->GetOutput());
         textureFilter->SetMaskImage(reader1->GetOutput());

         textureFilter->Update();

         const TextureFilterType::FeatureValueVector* output =3D textureFil=
ter->GetFeatureMeans();
         for (unsigned int i =3D 0; i < output->size(); ++i)
         {
                   std::cout << (*output)[i] << std::endl;
         }

         return EXIT_SUCCESS;
}



--_000_BL2PR06MB22921BBDAF860FC3FC8433CAA84A0BL2PR06MB2292namp_
Content-Type: text/html; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
hemas-microsoft-com:office:word" xmlns:m=3D"http://schemas.microsoft.com/of=
fice/2004/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
252">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:DengXian;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:DengXian;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
.MsoChpDefault
	{mso-style-type:export-only;}
/* Page Definitions */
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style>
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt"><o:p>&nbsp;</o:p></=
span></p>
<p class=3D"MsoNormal">Dear all,</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I am new to ITK and&nbsp; I want to calculate textur=
e features of&nbsp; NIFTI images.</p>
<p class=3D"MsoNormal">But the result of different images are all the same,=
 the result are 1 0 1 0 0 0
</p>
<p class=3D"MsoNormal">I=92d appreciate it if you could help me .</p>
<p class=3D"MsoNormal">Many thanks.</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Here attached the code :</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">#include &quot;itkImage.h&quot;</p>
<p class=3D"MsoNormal">#include &quot;itkScalarImageToTextureFeaturesFilter=
.h&quot;</p>
<p class=3D"MsoNormal">#include &quot;itkImageFileReader.h&quot;</p>
<p class=3D"MsoNormal">#include &quot;itkImageFileWriter.h&quot;</p>
<p class=3D"MsoNormal">#include &quot;itkNiftiImageIO.h&quot;</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">typedef itk::Image&lt;float, 3&gt; ImageType;</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">int main()</p>
<p class=3D"MsoNormal">{</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typ=
edef itk::ImageFileReader&lt;ImageType&gt;ReaderType;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rea=
derType::Pointer reader =3D ReaderType::New();</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rea=
derType::Pointer reader1 =3D ReaderType::New();</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rea=
der-&gt;SetFileName(&quot;C:/Users/studentx/Downloads/lung_data/NormalLung2=
/F63y/F63_2013.nii&quot;);</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rea=
der-&gt;Update();</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rea=
der1-&gt;SetFileName(&quot;C:/Users/studentx/Downloads/lung_data/NormalLung=
2/F63y/F63_2013_mask.nii&quot;);</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rea=
der1-&gt;Update();</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typ=
edef itk::Statistics::ScalarImageToTextureFeaturesFilter&lt;ImageType&gt; T=
extureFilterType;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tex=
tureFilterType::Pointer textureFilter =3D TextureFilterType::New();</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tex=
tureFilter-&gt;SetInput(reader-&gt;GetOutput());</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tex=
tureFilter-&gt;SetMaskImage(reader1-&gt;GetOutput());</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tex=
tureFilter-&gt;Update();</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con=
st TextureFilterType::FeatureValueVector* output =3D textureFilter-&gt;GetF=
eatureMeans();</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for=
 (unsigned int i =3D 0; i &lt; output-&gt;size(); &#43;&#43;i)</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</=
p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt;=
 (*output)[i] &lt;&lt; std::endl;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</=
p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret=
urn EXIT_SUCCESS;</p>
<p class=3D"MsoNormal">}</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_BL2PR06MB22921BBDAF860FC3FC8433CAA84A0BL2PR06MB2292namp_--

--===============1640266504==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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:
https://itk.org/mailman/listinfo/insight-users

--===============1640266504==--