Hello,<br><br>I am trying to create an image 20x20. Every pixel will have the value 0. Then, I have created an other function called OutputImage, with which I trying to see all the pixel's value on my window command prompt. The project is built correctly, but when I run it from the command window prompt I do not take any value. Could anybody find the problem?<br>
<br>Thanks in advance<br><br>-------------------------------------------------<br>-------------------------------------------------------<br>#include "itkImage.h"<br>#include "itkImageFileWriter.h"<br>
<br> <br>typedef itk::Image<unsigned char, 2> ImageType;<br> <br>static void CreateImage(ImageType::Pointer image);<br>void OutputImage(ImageType::Pointer image);<br> <br>int main(int, char *[])<br>{<br> // unsigned int pixelIndex; <br>
<br> ImageType::Pointer image = ImageType::New();<br> CreateImage(image);<br> OutputImage(image);<br> <br> <br> std::cout << "Original size: " << image->GetLargestPossibleRegion().GetSize() << std::endl;<br>
// std::cout << image-> GetPixel(pixelIndex) << std::endl;<br> <br> return EXIT_SUCCESS;<br>}<br> <br><br><br><br>void CreateImage(ImageType::Pointer image)<br>{<br> <br> ImageType::IndexType start;<br>
start.Fill(0);<br> <br> ImageType::SizeType size;<br> size.Fill(20);<br> <br> ImageType::RegionType region(start, size);<br> image->SetRegions(region);<br> image->Allocate();<br> image->FillBuffer(0);<br>
<br> <br>}<br><br><br><br><br>void OutputImage(ImageType::Pointer image)<br>{<br><br> for(unsigned int r = 0; r < 20; r++)<br> {<br> for(unsigned int c = 0; c < 20; c++)<br> {<br> ImageType::IndexType pixelIndex;<br>
pixelIndex[0] = r;<br> pixelIndex[1] = c;<br> <br> std::cout << image-> GetPixel(pixelIndex) << std::endl;<br> }<br> }<br><br> <br>}<br>