ImageProForClr.cpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. auto param = perameter->GetImgPrcPrmPtr();
  17. bool ret;
  18. if (param->GetBGRemoveType() == OTS_BGREMOVE_TYPE::Matrics)
  19. {
  20. ret = imgProEngine->SplitFieldImageIntoMatricsParticle(bseImg->GetBSEImgPtr(), a_PixelSize, fieldData->GetOTSFieldDataPtr());
  21. }
  22. else
  23. {
  24. ret = imgProEngine->RemoveBGByCVconnectivities(bseImg->GetBSEImgPtr(), a_PixelSize, fieldData->GetOTSFieldDataPtr());
  25. }
  26. return ret;
  27. }
  28. bool ImageProForClr::GetParticlesBySpecialPartGrayRange(CBSEImgClr^ bseImg, CIntRangeClr^ grayRange, CDoubleRangeClr^ diameterRange, double a_PixelSize, COTSFieldDataClr^ fieldData)
  29. {
  30. bool ret = imgProEngine->GetParticlesBySpecialGrayRange(bseImg->GetBSEImgPtr(), grayRange->GetCIntRangePtr(), diameterRange->GetCDoubleRangePtr(), a_PixelSize, fieldData->GetOTSFieldDataPtr());
  31. return ret;
  32. }
  33. bool ImageProForClr::CalcuParticleImagePropertes(COTSParticleClr^ particle, double a_PixelSize)
  34. {
  35. bool ret = imgProEngine->CalcuParticleImagePropertes(particle->GetOTSParticlePtr(), a_PixelSize);
  36. return ret;
  37. }
  38. BOOL ImageProForClr::MergeBigBoundaryParticles(System::Collections::Generic::List<COTSFieldDataClr^>^ allFields, double pixelSize, int scanFieldSize, Size ResolutionSize, System::Collections::Generic::List<COTSParticleClr^>^ mergedParts)
  39. {
  40. std::vector<COTSFieldDataPtr> allFlds;
  41. COTSParticleList mergedParticles;
  42. for each (auto f in allFields)
  43. {
  44. allFlds.push_back(f->GetOTSFieldDataPtr());
  45. }
  46. CSize CResolutionSize;
  47. CResolutionSize.cx = ResolutionSize.Width;
  48. CResolutionSize.cy = ResolutionSize.Height;
  49. bool ret = imgProEngine->MergeBigBoundaryParticles(allFlds, pixelSize, scanFieldSize, CResolutionSize, mergedParticles);
  50. for each (auto p in mergedParticles)
  51. {
  52. mergedParts->Add(gcnew COTSParticleClr(p));
  53. }
  54. return ret;
  55. }
  56. void ImageProForClr::RemoveBackGround(CBSEImgClr^ a_pImgIn, COTSImgProcPrmClr^ a_pImageProcessParam, CBSEImgClr^ a_pImgOut/*, long% foundedPixelNum*/)
  57. {
  58. // the background pixel will be 0,and the other part will be 255.
  59. //long num = 0;
  60. imgProEngine->RemoveBackGround(a_pImgIn->GetBSEImgPtr(), a_pImageProcessParam->GetImgPrcPrmPtr(), a_pImgOut->GetBSEImgPtr()/*, num*/);
  61. //foundedPixelNum = num;
  62. return;
  63. }
  64. void ImageProForClr::GetSpecialGrayRangeImage(CBSEImgClr^ a_pImgIn, CIntRangeClr^ a_SpecialGrayRange, CBSEImgClr^ a_pBinImgOut, long% foundedPixelNum)
  65. {
  66. long num = 0;
  67. imgProEngine->GetSpecialGrayRangeImage(a_pImgIn->GetBSEImgPtr(), a_SpecialGrayRange->GetCIntRangePtr(), a_pBinImgOut->GetBSEImgPtr(), num);
  68. foundedPixelNum = num;
  69. }
  70. }