Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include "itkImage.h"
  2. #include "itkImageFileReader.h"
  3.  
  4. int main()
  5. {
  6. mat m("filename");
  7. imshow("windowname", m);
  8. }
  9. // verify command line arguments
  10. if( argc < 2 )
  11. {
  12. std::cout << "usage: " << std::endl;
  13. std::cerr << argv[0] << " inputimagefile" << std::endl;
  14. return exit_failure;
  15. }
  16.  
  17. typedef itk::image<float, 2> imagetype;
  18. typedef itk::imagefilereader<imagetype> readertype;
  19.  
  20. readertype::pointer reader = readertype::new();
  21. reader->setfilename( argv[1] );
  22. reader->update();
  23.  
  24. std::cout << reader->getoutput()->getlargestpossibleregion().getsize()[0] << " "
  25. << reader->getoutput()->getlargestpossibleregion().getsize()[1] << std::endl;
  26.  
  27. // an example image had w = 200 and h = 100 (it is wider than it is tall). the above output
  28. // 200 100
  29. // so w = getsize()[0]
  30. // and h = getsize()[1]
  31.  
  32. // a pixel inside the region
  33. itk::index<2> indexinside;
  34. indexinside[0] = 150;
  35. indexinside[1] = 50;
  36. std::cout << reader->getoutput()-
  37. >getlargestpossibleregion().isinside(indexinside) << std::endl;
  38.  
  39. // a pixel outside the region
  40. itk::index<2> indexoutside;
  41. indexoutside[0] = 50;
  42. indexoutside[1] = 150;
  43. std::cout << reader->getoutput()- >getlargestpossibleregion().isinside(indexoutside) << std::endl;
  44.  
  45. // this means that the [0] component of the index is referencing the left to right (column) index
  46. // and the [1] component of index is referencing the top to bottom (row) index
  47.  
  48. return exit_success;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement