Hello,<br><br>I use visualstudio2010 and cmake.I am trying to read an image with the Command Prompt window (for example a .png image) and then get the data value of a pixel using the get() method. Finally, I want to take the value of the pixel on the Command Prompt window. So, I have created an imageReader object and an IndexType object as it is shown in the following code. As structures separately, the two objects seem to be correct, but I don't know how to connect them together to get my data value. Could someone help me with this problem?<br>
<br>Thanks<br>-----------------------code------------------------------<br>--------------------------------------------------------<br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br><br>#include "itkIndex.h"<br>
<br>int main(int argc, char *argv[])<br>{<br> if( argc < 2 )<br> {<br> std::cerr << "Usage: " << std::endl;<br> std::cerr << argv[0] << " inputImageFile" << std::endl;<br>
return EXIT_FAILURE;<br> }<br> <br> typedef itk::Image< unsigned short, 2 > ImageType;<br> typedef itk::ImageFileReader<ImageType> ReaderType;<br> <br> ReaderType::Pointer reader= ReaderType::New();<br>
reader->SetFileName(argv[1]);<br> <br> <br> //////////////////<br><br> // image object can be created<br> ImageType::Pointer image = ImageType::New();<br><br><br> ImageType::IndexType pixelIndex;<br> <br> pixelIndex[0] = 17; // x position<br>
pixelIndex[1] = 19; // y position<br><br><br> ImageType::PixelType pixelValue = image->GetPixel( pixelIndex );<br><br><br> std::cout << image->GetPixel(pixelIndex);<br><br>///////////////////////<br><br>
return EXIT_SUCCESS;<br>}<br><br><br>------------------CMakeLists.txt------------------<br>-------------------------------------------------------<br>cmake_minimum_required(VERSION 2.6)<br> <br>PROJECT(ImageFileReader)<br>
<br>FIND_PACKAGE(ITK REQUIRED)<br>INCLUDE(${ITK_USE_FILE})<br> <br> <br>ADD_EXECUTABLE(myproject myproject.cxx)<br>TARGET_LINK_LIBRARIES(myproject ITKIO ITKCommon)<br>