ICM.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __ICM_H__
  2. #define __ICM_H__
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <assert.h>
  7. #include "mrf.h"
  8. #include "LinkedBlockList.h"
  9. namespace OBJREC {
  10. class ICM : public MRF{
  11. public:
  12. ICM(int width, int height, int nLabels, EnergyFunction *eng);
  13. ICM(int nPixels, int nLabels,EnergyFunction *eng);
  14. ~ICM();
  15. void setNeighbors(int pix1, int pix2, CostVal weight);
  16. Label getLabel(int pixel){return(m_answer[pixel]);};
  17. void setLabel(int pixel,Label label){m_answer[pixel] = label;};
  18. Label* getAnswerPtr(){return(m_answer);};
  19. void clearAnswer();
  20. void setParameters(int /*numParam*/, void * /*param*/){printf("No optional parameters to set"); exit(1);}
  21. EnergyVal smoothnessEnergy();
  22. EnergyVal dataEnergy();
  23. protected:
  24. void setData(DataCostFn dcost);
  25. void setData(CostVal* data);
  26. void setSmoothness(SmoothCostGeneralFn cost);
  27. void setSmoothness(CostVal* V);
  28. void setSmoothness(int smoothExp,CostVal smoothMax, CostVal lambda);
  29. void setCues(CostVal* hCue, CostVal* vCue);
  30. void initializeAlg();
  31. void optimizeAlg(int nIterations);
  32. private:
  33. Label *m_answer;
  34. CostVal *m_V;
  35. CostVal *m_D;
  36. CostVal *m_horizWeights;
  37. CostVal *m_vertWeights;
  38. DataCostFn m_dataFn;
  39. SmoothCostGeneralFn m_smoothFn;
  40. bool m_needToFreeV;
  41. typedef struct NeighborStruct{
  42. int to_node;
  43. CostVal weight;
  44. } Neighbor;
  45. LinkedBlockList *m_neighbors;
  46. };
  47. }
  48. #endif /* __ICM_H__ */