Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "itkImage.h"
- #include "itkImageFileReader.h"
- int main()
- {
- mat m("filename");
- imshow("windowname", m);
- }
- // verify command line arguments
- if( argc < 2 )
- {
- std::cout << "usage: " << std::endl;
- std::cerr << argv[0] << " inputimagefile" << std::endl;
- return exit_failure;
- }
- typedef itk::image<float, 2> imagetype;
- typedef itk::imagefilereader<imagetype> readertype;
- readertype::pointer reader = readertype::new();
- reader->setfilename( argv[1] );
- reader->update();
- std::cout << reader->getoutput()->getlargestpossibleregion().getsize()[0] << " "
- << reader->getoutput()->getlargestpossibleregion().getsize()[1] << std::endl;
- // an example image had w = 200 and h = 100 (it is wider than it is tall). the above output
- // 200 100
- // so w = getsize()[0]
- // and h = getsize()[1]
- // a pixel inside the region
- itk::index<2> indexinside;
- indexinside[0] = 150;
- indexinside[1] = 50;
- std::cout << reader->getoutput()-
- >getlargestpossibleregion().isinside(indexinside) << std::endl;
- // a pixel outside the region
- itk::index<2> indexoutside;
- indexoutside[0] = 50;
- indexoutside[1] = 150;
- std::cout << reader->getoutput()- >getlargestpossibleregion().isinside(indexoutside) << std::endl;
- // this means that the [0] component of the index is referencing the left to right (column) index
- // and the [1] component of index is referencing the top to bottom (row) index
- return exit_success;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement