PageRenderTime 72ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/image++/src/irtkFileOpenCVToImage.cc

https://gitlab.com/mariadeprez/irtk-public
C++ | 62 lines | 38 code | 12 blank | 12 comment | 2 complexity | 4525ad91e90e89879b3eb6de6f3839c4 MD5 | raw file
  1. /*=========================================================================
  2. Library : Image Registration Toolkit (IRTK)
  3. Module : $Id$
  4. Copyright : Imperial College, Department of Computing
  5. Visual Information Processing (VIP), 2008 onwards
  6. Date : $Date$
  7. Version : $Revision$
  8. Changes : $Author$
  9. =========================================================================*/
  10. #include <irtkImage.h>
  11. #include <irtkFileToImage.h>
  12. #ifdef HAS_OPENCV
  13. #include <irtkImageToOpenCv.h>
  14. const char *irtkFileOpenCVToImage::NameOfClass()
  15. {
  16. return "irtkFileOpenCVToImage";
  17. }
  18. int irtkFileOpenCVToImage::CheckHeader(const char *filename)
  19. {
  20. IplImage *pimage = NULL;
  21. pimage= cvLoadImage(filename,0);
  22. if(pimage != NULL){
  23. cvReleaseImage(&pimage);
  24. return 1;
  25. }else{
  26. return 0;
  27. }
  28. }
  29. void irtkFileOpenCVToImage::SetInput(const char *filename){
  30. _pimage = NULL;
  31. _pimage= cvLoadImage(filename,0);
  32. // Read header
  33. this->ReadHeader();
  34. }
  35. irtkImage * irtkFileOpenCVToImage::GetOutput(){
  36. irtkGreyImage *output;
  37. irtkImageToOpenCv<irtkGreyPixel> itocg;
  38. itocg.SetOutput(_pimage);
  39. itocg.Invert();
  40. output = itocg.GetInput();
  41. return (irtkImage*)output;
  42. }
  43. void irtkFileOpenCVToImage::ReadHeader()
  44. {
  45. this->_type = IRTK_VOXEL_SHORT;
  46. this->_bytes = 2;
  47. }
  48. #endif