|
@@ -1602,7 +1602,7 @@ namespace OTSIMGPROC
|
|
|
|
|
|
Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
Mat labels = Mat::zeros(cvcopyImg.size(), CV_32S);
|
|
|
Mat stats, centroids;
|
|
|
int number = connectedComponentsWithStats(cvcopyImg, labels, stats, centroids, 8, CV_32S);
|
|
@@ -2147,11 +2147,7 @@ namespace OTSIMGPROC
|
|
|
BOOL COTSImageProcess::GetSegmentList(long left, long top, long a_nWidth, long a_nHeight, const BYTE* a_pPixel, COTSSegmentsList& a_listSegments)
|
|
|
{
|
|
|
ASSERT(a_pPixel);
|
|
|
- if (!a_pPixel)
|
|
|
- {
|
|
|
- //LogErrorTrace(__FILE__, __LINE__, _T("GetSegments: there is no image data"));
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
long nImgSize = a_nWidth * a_nHeight;
|
|
|
|
|
@@ -2703,41 +2699,52 @@ namespace OTSIMGPROC
|
|
|
|
|
|
std::vector<CIntRangePtr> rngs = CalcuGrayLevelRange(onePartImg);
|
|
|
|
|
|
+
|
|
|
|
|
|
COTSFieldDataPtr partData = COTSFieldDataPtr(new COTSFieldData());
|
|
|
std::map<int, std::vector<COTSParticlePtr>> partAreaMap;
|
|
|
for (int i = 0; i < rngs.size(); i++)
|
|
|
{
|
|
|
partAreaMap.clear();
|
|
|
- GetParticlesBySpecialGrayRange(onePartImg, rngs[i], CDoubleRangePtr(new CDoubleRange(0, 1000)), a_PixelSize, partData);
|
|
|
+ GetParticlesBySpecialGrayRange(onePartImg, rngs[i], CDoubleRangePtr(new CDoubleRange(0, 2000)), a_PixelSize, partData);
|
|
|
|
|
|
|
|
|
|
|
|
- for (auto p : partData->GetParticleList())
|
|
|
+ for (auto p : partData->GetParticleList())//sorting and filtering
|
|
|
{
|
|
|
- partAreaMap[p->GetPixelArea()].push_back(p);
|
|
|
+ /*if (p->GetActualArea() > 50)
|
|
|
+ {*/
|
|
|
+ partAreaMap[p->GetPixelArea()].push_back(p);
|
|
|
+ //}
|
|
|
+
|
|
|
}
|
|
|
- auto theBiggestPart = partAreaMap.rbegin()->second[0];
|
|
|
- theBiggestPart->CalXRayPos();
|
|
|
- std::map<int, std::vector<COTSParticlePtr>>::reverse_iterator it;
|
|
|
- auto partsegs = theBiggestPart->GetFeature()->GetSegmentsList();
|
|
|
- it = partAreaMap.rbegin()++;
|
|
|
- for (;it!=partAreaMap.rend();it++)
|
|
|
+ if(partAreaMap.size()>0)
|
|
|
{
|
|
|
- for (auto sameAreaP : it->second)
|
|
|
- {
|
|
|
- auto segs = sameAreaP->GetFeature()->GetSegmentsList();
|
|
|
- for (auto s : segs)
|
|
|
+ auto theBiggestPart = partAreaMap.rbegin()->second[0];
|
|
|
+ theBiggestPart->CalXRayPos();
|
|
|
+ std::map<int, std::vector<COTSParticlePtr>>::reverse_iterator it;
|
|
|
+ auto partsegs = theBiggestPart->GetFeature()->GetSegmentsList();
|
|
|
+ it = partAreaMap.rbegin()++;
|
|
|
+ for (; it != partAreaMap.rend(); it++)
|
|
|
{
|
|
|
- partsegs.push_back(s);
|
|
|
+ for (auto sameAreaP : it->second)
|
|
|
+ {
|
|
|
+ auto segs = sameAreaP->GetFeature()->GetSegmentsList();
|
|
|
+ for (auto s : segs)
|
|
|
+ {
|
|
|
+ partsegs.push_back(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ theBiggestPart->GetFeature()->SetSegmentsList(partsegs, true);
|
|
|
+ theBiggestPart->SetFieldId(a_pOTSPart->GetFieldId());
|
|
|
+ theBiggestPart->SetAnalysisId(a_pOTSPart->GetAnalysisId());
|
|
|
+ a_pOTSPart->AddSubParticle(theBiggestPart);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- theBiggestPart->GetFeature()->SetSegmentsList(partsegs, true);
|
|
|
- theBiggestPart->SetFieldId(a_pOTSPart->GetFieldId());
|
|
|
- theBiggestPart->SetAnalysisId(a_pOTSPart->GetAnalysisId());
|
|
|
- a_pOTSPart->AddSubParticle(theBiggestPart);
|
|
|
+
|
|
|
|
|
|
/*for (auto p : partData->GetParticleList())
|
|
|
{
|