ImageProForClr.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "stdafx.h"
  2. #include "ImageProForClr.h"
  3. namespace OTSCLRINTERFACE
  4. {
  5. ImageProForClr::ImageProForClr(COTSImgProcPrmClr^ perameter)
  6. {
  7. imgProEngine = new COTSImageProcess(perameter->GetImgPrcPrmPtr());
  8. }
  9. void ImageProForClr::UpdateImageProcessParam(COTSImgProcPrmClr^ perameter)
  10. {
  11. imgProEngine->UpdateImageProcessParam(perameter->GetImgPrcPrmPtr());
  12. }
  13. bool ImageProForClr::GetFieldDataFromImage(CBSEImgClr^ bseImg, COTSImgProcPrmClr^ perameter, double a_PixelSize, COTSFieldDataClr^ fieldData)
  14. {
  15. imgProEngine->UpdateImageProcessParam(perameter->GetImgPrcPrmPtr());
  16. bool ret = imgProEngine->RemoveBGByCVconnectivities(bseImg->GetBSEImgPtr(), a_PixelSize, fieldData->GetOTSFieldDataPtr());
  17. if (perameter->GetImgPrcPrmPtr()->GetOverlapParam() > 0)
  18. {
  19. imgProEngine->FilterParticlesByOverlap(fieldData->GetOTSFieldDataPtr());
  20. }
  21. return ret;
  22. }
  23. bool ImageProForClr::GetParticlesBySpecialPartGrayRange(CBSEImgClr^ bseImg, CIntRangeClr^ grayRange, CDoubleRangeClr^ diameterRange, double a_PixelSize, COTSFieldDataClr^ fieldData)
  24. {
  25. bool ret = imgProEngine->GetParticlesBySpecialGrayRange(bseImg->GetBSEImgPtr(), grayRange->GetCIntRangePtr(), diameterRange->GetCDoubleRangePtr(), a_PixelSize, fieldData->GetOTSFieldDataPtr());
  26. return ret;
  27. }
  28. bool ImageProForClr::CalcuParticleImagePropertes(COTSParticleClr^ particle, double a_PixelSize)
  29. {
  30. bool ret = imgProEngine->CalcuParticleImagePropertes(particle->GetOTSParticlePtr(), a_PixelSize);
  31. return ret;
  32. }
  33. BOOL ImageProForClr::MergeBigBoundaryParticles(System::Collections::Generic::List<COTSFieldDataClr^>^ allFields, double pixelSize, int scanFieldSize, Size ResolutionSize, System::Collections::Generic::List<COTSParticleClr^>^ mergedParts)
  34. {
  35. std::vector<COTSFieldDataPtr> allFlds;
  36. COTSParticleList mergedParticles;
  37. for each (auto f in allFields)
  38. {
  39. allFlds.push_back(f->GetOTSFieldDataPtr());
  40. }
  41. CSize CResolutionSize;
  42. CResolutionSize.cx = ResolutionSize.Width;
  43. CResolutionSize.cy = ResolutionSize.Height;
  44. bool ret = imgProEngine->MergeBigBoundaryParticles(allFlds, pixelSize, scanFieldSize, CResolutionSize, mergedParticles);
  45. for each (auto p in mergedParticles)
  46. {
  47. mergedParts->Add(gcnew COTSParticleClr(p));
  48. }
  49. return ret;
  50. }
  51. void ImageProForClr::RemoveBackGround(CBSEImgClr^ a_pImgIn, COTSImgProcPrmClr^ a_pImageProcessParam, CBSEImgClr^ a_pImgOut, long% foundedPixelNum)
  52. {
  53. // the background pixel will be 0,and the other part will be 255.
  54. long num = 0;
  55. imgProEngine->RemoveBackGround(a_pImgIn->GetBSEImgPtr(), a_pImageProcessParam->GetImgPrcPrmPtr(), a_pImgOut->GetBSEImgPtr(), num);
  56. foundedPixelNum = num;
  57. return;
  58. }
  59. void ImageProForClr::GetSpecialGrayRangeImage(CBSEImgClr^ a_pImgIn, CIntRangeClr^ a_SpecialGrayRange, CBSEImgClr^ a_pBinImgOut, long% foundedPixelNum)
  60. {
  61. long num = 0;
  62. imgProEngine->GetSpecialGrayRangeImage(a_pImgIn->GetBSEImgPtr(), a_SpecialGrayRange->GetCIntRangePtr(), a_pBinImgOut->GetBSEImgPtr(), num);
  63. foundedPixelNum = num;
  64. }
  65. }