ImageProForClr.cpp 3.3 KB

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