<div>Respected Sir,</div>
<div> </div>
<div> </div>
<div>I have a gray scale image of png format.Iam trying extract Pixel information but my program crashes satting unhandled exception.Iam posting the code .Please rectify the error.Awaiting your response.</div>
<div><br clear="all"><font color="#0000ff" size="2">
<p>#if</p></font><font size="2"> </font><font color="#0000ff" size="2">defined</font><font size="2">(_MSC_VER)</font><font color="#0000ff" size="2">
<p>#pragma</p></font><font size="2"> </font><font color="#0000ff" size="2">warning</font><font size="2"> ( </font><font color="#0000ff" size="2">disable</font><font size="2"> : 4786 )</font><font color="#0000ff" size="2">
<p>#endif</p>
<p>#include</p></font><font size="2"> </font><font color="#800000" size="2">"itkImage.h"</font><font color="#0000ff" size="2">
<p>#include</p></font><font size="2"> </font><font color="#800000" size="2">"itkImageFileReader.h"</font><font color="#008000" size="2">
<p>// Software Guide : EndCodeSnippet</p></font><font color="#0000ff" size="2">
<p>int</p></font><font size="2"> main( </font><font color="#0000ff" size="2">int</font><font size="2"> , </font><font color="#0000ff" size="2">char</font><font size="2"> * argv[])
<p>{</p>
<p></p>
<p></p></font><font color="#0000ff" size="2">typedef</font><font size="2"> </font><font color="#0000ff" size="2">unsigned</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2"> PixelType;
<p></p></font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">unsigned</font><font size="2"> </font><font color="#0000ff" size="2">int</font><font size="2"> Dimension = 2;
<p></p></font><font color="#0000ff" size="2">typedef</font><font size="2"> itk::Image< PixelType, Dimension > ImageType;</font><font color="#008000" size="2"></font><font size="2">
<p></p></font><font color="#0000ff" size="2">typedef</font><font size="2"> itk::ImageFileReader< ImageType > ReaderType;
<p>ReaderType::Pointer reader = ReaderType::New();</p>
<p></p>
<p></p></font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2"> * filename = argv[1];
<p>reader->SetFileName( filename );</p>
<p></p>
<p>reader->Update();</p>
<p></p>
<p>ImageType::Pointer image = reader->GetOutput();</p>
<p>ImageType::IndexType start;</p>
<p>ImageType::SizeType size;</p>
<p>size[0] = 100; </p></font><font color="#008000" size="2">// size along X</font><font size="2">
<p>size[1] = 100; </p></font><font color="#008000" size="2">// size along Y</font><font color="#008000" size="2"></font><font size="2">
<p>start[0] = 0; </p></font><font color="#008000" size="2">// first index on X</font><font size="2">
<p>start[1] = 0; </p></font><font color="#008000" size="2">// first index on Y</font><font color="#008000" size="2"></font><font size="2">
<p>ImageType::RegionType region;</p>
<p>region.SetSize( size );</p>
<p>region.SetIndex( start );</p>
<p></p>
<p>image->SetRegions( region );</p>
<p>image->Allocate();</p>
<p>ImageType::PixelType initialValue = 0;</p>
<p>image->FillBuffer( initialValue );</p>
<p>ImageType::IndexType pixelIndex;</p>
<p></p>
<p>pixelIndex[0] = 27; </p></font><font color="#008000" size="2">// x position</font><font size="2">
<p>pixelIndex[1] = 29; </p></font><font color="#008000" size="2">// y position</font><font color="#008000" size="2"></font><font size="2">
<p></p>
<p>ImageType::PixelType pixelValue = image->GetPixel( pixelIndex );</p>
<p></p>
<p>image->SetPixel( pixelIndex, pixelValue+1 );</p>
<p></p>
<p></p></font><font color="#0000ff" size="2">return</font><font size="2"> 0;</font><br>-- <br>Warm Regards<br><br>Raghu Prasad </div>