|
@@ -1177,8 +1177,7 @@ namespace OTSIMGPROC
|
|
|
{
|
|
|
|
|
|
// get the area image
|
|
|
- COTSImageProcess::BErode3(pPixel, pTempImg, 5, nHeightImg, nWidthImg);
|
|
|
- COTSImageProcess::BDilate3(pTempImg, pPixel, 5, nHeightImg, nWidthImg);
|
|
|
+
|
|
|
|
|
|
Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);
|
|
|
Mat blurImg;
|
|
@@ -1362,8 +1361,7 @@ namespace OTSIMGPROC
|
|
|
auto s = downEdgeSeries.rbegin()->second;
|
|
|
pRangeFirst->SetEnd((long)(s[s.size() - 1]));
|
|
|
}
|
|
|
- /*delete[] nBSEChart;
|
|
|
- delete[] n_aBSEChart;*/
|
|
|
+
|
|
|
return pRangeFirst;
|
|
|
}
|
|
|
void COTSImageProcess::RemoveBackGround(CBSEImgPtr a_pImgIn, COTSImageProcessParamPtr a_pImageProcessParam, CBSEImgPtr a_pBinImgOut,long& foundedPixelNum)
|
|
@@ -1378,34 +1376,31 @@ namespace OTSIMGPROC
|
|
|
|
|
|
long nImgSize = nWidthImg * nHeightImg;
|
|
|
|
|
|
- BYTE* pTempImg = new BYTE[nImgSize];
|
|
|
- BYTE* pTempImg2 = new BYTE[nImgSize];
|
|
|
+ BYTE* pTempImg = new BYTE[nImgSize];
|
|
|
|
|
|
BYTE* pSrcImg = a_pImgIn->GetImageDataPointer();
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
BYTE* pPixel = new byte[nImgSize];
|
|
|
|
|
|
|
|
|
|
|
|
long nBGStart;
|
|
|
long nBGEnd;
|
|
|
-
|
|
|
+ long nPartStart;
|
|
|
+ long nPartEnd;
|
|
|
long nNumParticle = 0;
|
|
|
if (a_pImageProcessParam->GetBGRemoveType() == OTS_BGREMOVE_TYPE::MANUAL)
|
|
|
{
|
|
|
nBGStart = a_pImageProcessParam->GetBGGray().GetStart();
|
|
|
nBGEnd = a_pImageProcessParam->GetBGGray().GetEnd();
|
|
|
+ nPartStart = a_pImageProcessParam->GetParticleGray().GetStart();
|
|
|
+ nPartEnd = a_pImageProcessParam->GetParticleGray().GetEnd();
|
|
|
|
|
|
// delete background
|
|
|
for (unsigned int i = 0; i < nImgSize; i++)
|
|
|
{
|
|
|
- if (pTempImg2[i] >= nBGStart && pTempImg2[i] <= nBGEnd)
|
|
|
+ if (pSrcImg[i] >= nBGStart && pSrcImg[i] <= nBGEnd)
|
|
|
{
|
|
|
pPixel[i] = 0;
|
|
|
}
|
|
@@ -1414,14 +1409,17 @@ namespace OTSIMGPROC
|
|
|
pPixel[i] = 255;
|
|
|
nNumParticle++;
|
|
|
}
|
|
|
+ if (pSrcImg[i]<nPartStart || pSrcImg[i]>nPartEnd)
|
|
|
+ {
|
|
|
+ pPixel[i] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
COTSImageProcess::BErode3(pPixel, pTempImg, 5, nHeightImg, nWidthImg);
|
|
|
COTSImageProcess::BDilate3(pTempImg, pPixel, 5, nHeightImg, nWidthImg);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- /*CBSEImgPtr srcImg2 = CBSEImgPtr(new CBSEImg());
|
|
|
- srcImg2->SetImageData(a_pImgIn, nWidthImg, nHeightImg);*/
|
|
|
+
|
|
|
auto range = CalBackground(a_pImgIn);
|
|
|
nBGStart = range->GetStart();
|
|
|
|
|
@@ -1433,7 +1431,7 @@ namespace OTSIMGPROC
|
|
|
case OTS_AUTOBGREMOVE_TYPE::DOWNWARD:
|
|
|
for (unsigned int i = 0; i < nImgSize; i++)
|
|
|
{
|
|
|
- if (pTempImg2[i] <= nBGEnd)
|
|
|
+ if (pSrcImg[i] <= nBGEnd)
|
|
|
{
|
|
|
pPixel[i] = 0;
|
|
|
}
|
|
@@ -1447,7 +1445,7 @@ namespace OTSIMGPROC
|
|
|
case OTS_AUTOBGREMOVE_TYPE::UPWARD:
|
|
|
for (unsigned int i = 0; i < nImgSize; i++)
|
|
|
{
|
|
|
- if (pTempImg2[i] >= nBGStart)
|
|
|
+ if (pSrcImg[i] >= nBGStart)
|
|
|
{
|
|
|
pPixel[i] = 0;
|
|
|
}
|
|
@@ -1461,7 +1459,7 @@ namespace OTSIMGPROC
|
|
|
case OTS_AUTOBGREMOVE_TYPE::MIDDLE:
|
|
|
for (unsigned int i = 0; i < nImgSize; i++)
|
|
|
{
|
|
|
- if (pTempImg2[i] >= nBGStart && pTempImg2[i] <= nBGEnd)
|
|
|
+ if (pSrcImg[i] >= nBGStart && pSrcImg[i] <= nBGEnd)
|
|
|
{
|
|
|
pPixel[i] = 0;
|
|
|
}
|
|
@@ -1482,7 +1480,7 @@ namespace OTSIMGPROC
|
|
|
|
|
|
foundedPixelNum = nNumParticle;
|
|
|
delete[] pTempImg;
|
|
|
- delete[] pTempImg2;
|
|
|
+ //delete[] pTempImg2;
|
|
|
return ;
|
|
|
}
|
|
|
BOOL COTSImageProcess::GetParticles(long left, long top, long a_nWidth, long a_nHeight, const BYTE* a_pPixel, COTSParticleList& a_listParticles)
|