OTSImageProcess.h 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #include "OTSParticle.h"
  3. #include "OTSImageProcessParam.h"
  4. #include <OTSFieldData.h>
  5. namespace OTSIMGPROC {
  6. using namespace OTSDATA;
  7. // Re-magnification
  8. const int nImage_Size = 3;
  9. //make matrix filled with 255
  10. const int nBlackColor = 255;
  11. //make binary processing parameter 128
  12. const int nProcessParam = 100;
  13. //picture size
  14. const int nPictureSize = 128;
  15. // added to filtered pixels
  16. const double delta = 0;
  17. using namespace std;
  18. class __declspec(dllexport) COTSImageProcess
  19. {
  20. public:
  21. COTSImageProcess();
  22. ~COTSImageProcess();
  23. // image process
  24. // morphology
  25. // LPBYTE source£º binary image pointer input£¬0, and 255
  26. // LPBYTE target: image pointer output
  27. // WORD rows: image height
  28. // WORD clumns: image width
  29. // WORD wDegree: 1~8, eight direction selction.
  30. // erode image with a structure of verticle 3 element
  31. static void BErodeVertical3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  32. // erode image with a left 45 degree structure of 3 element
  33. static void BErodeLeft45Degree3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  34. // erode image with a structure of horizontal 3 element
  35. static void BErodeHorizontal3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  36. // erode image with a right 45 degree structure of 3 element
  37. static void BErodeRight45Degree3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  38. // dilate image with a structure of verticle 3 element
  39. static void BDilateVertical3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  40. // dilate image with a left 45 degree structure of 3 element
  41. static void BDilateLeft45Degree3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  42. // dilate image with a structure of horizontal 3 element
  43. static void BDilateHorizontal3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  44. // dilate image with a right 45 degree structure of 3 element
  45. static void BDilateRight45Degree3(LPBYTE source, LPBYTE target, WORD rows, WORD columns);
  46. // erode image with a structure of verticle 8 element
  47. static void BErode3(LPBYTE source, LPBYTE target, WORD wDegree, WORD rows, WORD columns);
  48. // dilate image with a structure of verticle 8 element
  49. static void BDilate3(LPBYTE source, LPBYTE target, WORD wDegree, WORD rows, WORD columns);
  50. // ReZoom the picture with re-magnification
  51. static BOOL ReZoom(CString InPutPath, CString OutPutPath);
  52. static BOOL RemoveBSEImageBG(CBSEImgPtr m_pBSEImg, COTSImageProcessParamPtr a_pImageProcessParam, COTSFieldDataPtr m_pFieldData);
  53. static BOOL RemoveBGByFindContour(CBSEImgPtr m_pBSEImg, COTSImageProcessParamPtr a_pImageProcessParam, COTSFieldDataPtr m_pFieldData);
  54. static BOOL RemoveBGByCVconnectivities(CBSEImgPtr m_pBSEImg, COTSImageProcessParamPtr a_pImageProcessParam, double a_pixelSize, COTSFieldDataPtr m_pFieldData);
  55. static BOOL GetParticlesBySpecialGrayRange(CBSEImgPtr m_pBSEImg, CIntRangePtr a_grayRange, CDoubleRangePtr a_diameterRange, double a_pixelSize, COTSFieldDataPtr m_pFieldData);
  56. static CIntRangePtr CalBackground(CBSEImgPtr m_pBSEImg);
  57. static void GetSpecialGrayRangeImage(CBSEImgPtr a_pImgIn, CIntRangePtr a_SpecialGrayRange, CBSEImgPtr a_pBinImgOut, long& foundedPixelNum);
  58. static void RemoveBackGround(CBSEImgPtr a_pImgIn, COTSImageProcessParamPtr a_pImageProcessParam, CBSEImgPtr a_pImgOut,long& foundedPixelNum);
  59. static BOOL CalcuParticleImagePropertes(COTSParticlePtr part, double a_PixelSize);
  60. static BOOL MergeBigBoundaryParticles(COTSFieldDataList allFields, double pixelSize, int scanFieldSize, CSize ResolutionSize, COTSParticleList& mergedParts);
  61. protected:
  62. static BOOL GetParticles(long left, long top, long a_nWidth, long a_nHeight, const BYTE* a_pPixel, COTSParticleList& a_listParticles);
  63. static BOOL GetOneParticleFromROI(long left, long top, long a_nWidth, long a_nHeight, const BYTE* a_pPixel, COTSParticleList& a_listParticles);
  64. static BOOL GetSegmentList(long left, long top, long a_nWidth, long a_nHeight, const BYTE* a_pPixel, COTSSegmentsList& a_listSegments);
  65. static BOOL GetFeatureList(COTSSegmentsList& a_listSegments, COTSFeatureList& a_listFeatures);
  66. static BOOL ChangeFeaturelist(COTSFeatureList& a_listFeatures, COTSParticleList& a_listParticle);
  67. };
  68. }