Ver código fonte

restore the morphology process before the opencv connectedComponentsWithStats method.

gsp 3 anos atrás
pai
commit
85de5c2ae8

+ 20 - 60
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -1357,39 +1357,17 @@ namespace OTSIMGPROC
 
 							if (v == label)
 							{
-								imageROI.at<uchar>(row, col) = 255;
-							}
-							else
-							{
-								imageROI.at<uchar>(row, col) = 0;//set the value to 0,so we won't consider it when we find segment and feature in this ROI.
+								imageROI.at<uchar>(row, col) = 255;//set the value to 255,so we won't consider other pixel when we find segment and feature in this ROI.
 							}
+						
 
 						}
 
 					}
-					//COTSParticleList listParticleInROI;
+				
 					GetParticles(rectMax.x, rectMax.y, rectMax.width, rectMax.height, imageROI.data, listParticleOut);
 
-					//if (listParticleInROI.size() >= 1)
-					//{
-					//	
-					//	//find the biggest particle in this group.
-					//	COTSParticlePtr bigP = listParticleInROI[0];
-					//	for (auto p : listParticleInROI)
-					//	{
-					//		//double partArea = p->GetArea()* a_pixelSize* a_pixelSize;
-					//		if (p->GetArea() > bigP->GetArea())
-					//		{
-					//			bigP = p;
-					//		}
-					//		/*if (partArea >= partAreaMin && partArea < partAreaMax)
-					//		{
-					//			listParticleOut.push_back(p);
-					//		}*/
-					//	}
-					//	listParticleOut.push_back(bigP);
-
-					//}
+
 				  
 				  }
 
@@ -1537,10 +1515,7 @@ namespace OTSIMGPROC
 							{
 								imageROI.at<uchar>(row, col) = 255;
 							}
-							else
-							{
-								imageROI.at<uchar>(row, col) = 0;//set the value to 0,so we won't consider it when we find segment and feature in this ROI.
-							}
+							
 
 						}
 
@@ -1549,22 +1524,8 @@ namespace OTSIMGPROC
 
 
 		
-					//COTSParticleList listParticleInROI;
 					GetParticles(rectMax.x, rectMax.y, rectMax.width, rectMax.height, imageROI.data, listParticleOut);//We will find more than one particle in one ROI. and We cann't decide which are the valid and not valid.So we will do another filter again later.
-					//if (listParticleInROI.size() >= 1)
-					//{
-					//	//find the biggest particle in this group.
-					//	COTSParticlePtr bigP = listParticleInROI[0];
-					//	for (auto p : listParticleInROI)
-					//	{
-					//		if (p->GetArea() > bigP->GetArea())
-					//		{
-					//			bigP = p;
-					//		}
-					//	}
-					//	listParticleOut.push_back(bigP);
-
-					//}
+					
 				}
 				
 
@@ -1574,13 +1535,12 @@ namespace OTSIMGPROC
 
 			// form a image only have particles on
 			//COTSSegmentsList listImage;
-			COTSParticleList listParticleOut2;
+			
 			for (auto pParticle : listParticleOut)
 			{
 				int area = pParticle->GetArea();
 				double pActualArea = area * a_pixelSize * a_pixelSize;
-				if (pActualArea >= areaStart && pActualArea < areaEnd)// do the second filter to remove invalid particles.
-				{
+			
 					COTSFeaturePtr pFeature = pParticle->GetFeature();
 					COTSSegmentsList listSegment = pFeature->GetSegmentsList();
 
@@ -1610,13 +1570,13 @@ namespace OTSIMGPROC
 					BYTE nAveGray = (BYTE)(nPixelAll / nPixelNum);
 					pParticle->SetAveGray(nAveGray);
 
-					listParticleOut2.push_back(pParticle);
-				}
+					
+				
 				
 				
 
 			}
-			m_pFieldData->SetParticleList(listParticleOut2);
+			m_pFieldData->SetParticleList(listParticleOut);
 		}
 
 
@@ -1750,12 +1710,12 @@ namespace OTSIMGPROC
 				}
 		
 			}
-			/*COTSImageProcess::BErode3(pPixel, pTempImg, 5, nHeightImg, nWidthImg);
-			COTSImageProcess::BDilate3(pTempImg, pPixel, 5, nHeightImg, nWidthImg);*/
+			/*COTSImageProcess::BErode3(pPixel, pTempImg, 3, nHeightImg, nWidthImg);
+			COTSImageProcess::BDilate3(pTempImg, pPixel, 3, nHeightImg, nWidthImg);*/
 
-			//Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);// use the medianblur method to achieve the same effect as open morphology(errod and dialate).
-			//medianBlur(cvcopyImg, cvcopyImg, 3);
-			//pPixel = cvcopyImg.data;
+			Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);// use the medianblur method to achieve the same effect as open morphology(errod and dialate).
+			medianBlur(cvcopyImg, cvcopyImg, 3);
+			pPixel = cvcopyImg.data;
 		a_pBinImgOut->SetImageData(pPixel, nWidthImg, nHeightImg);
 
 		foundedPixelNum = nNumParticle;
@@ -1813,8 +1773,8 @@ namespace OTSIMGPROC
 					pPixel[i] = 0;
 				}
 			}
-			//COTSImageProcess::BErode3(pPixel, pTempImg, 3, nHeightImg, nWidthImg);
-			//COTSImageProcess::BDilate3(pTempImg, pPixel, 3, nHeightImg, nWidthImg);
+			COTSImageProcess::BErode3(pPixel, pTempImg, 3, nHeightImg, nWidthImg);
+			COTSImageProcess::BDilate3(pTempImg, pPixel, 3, nHeightImg, nWidthImg);
 			//Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);// use the medianblur method to achieve the same effect as open morphology(errod and dialate).
 			//medianBlur(cvcopyImg, cvcopyImg, 5);
 			//pPixel = cvcopyImg.data;
@@ -1877,9 +1837,9 @@ namespace OTSIMGPROC
 			default:
 				break;
 			}
-			/*COTSImageProcess::BErode3(pPixel, pTempImg, 3, nHeightImg, nWidthImg);
+			COTSImageProcess::BErode3(pPixel, pTempImg, 3, nHeightImg, nWidthImg);
 			COTSImageProcess::BDilate3(pTempImg, pPixel, 3, nHeightImg, nWidthImg);
-			Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);
+			/*Mat cvcopyImg = Mat(nHeightImg, nWidthImg, CV_8UC1, pPixel);
 			medianBlur(cvcopyImg, cvcopyImg, 5);
 			pPixel = cvcopyImg.data;*/
 		}

+ 0 - 14
OTSIncAMeasureApp/0-OTSModel/Measure/BSEPicData/COTSFieldData.cs

@@ -188,20 +188,6 @@ namespace OTSModelSharp
 
 
 
-                if (dPartArea > (double)dAreaHigh)
-                {
-                    pParticle.SetType((int)otsdataconst.OTS_PARTCLE_TYPE.OVERSIZE);
-                    overSizenum += 1;
-                    continue;
-                }
-
-                else if (dPartArea < (double)dAreaLow)
-                {
-                    pParticle.SetType((int)otsdataconst.OTS_PARTCLE_TYPE.SMALL);
-                    tooSmallnum += 1;
-                    continue;
-                }
-
 
                 pParticle.SetTagId(nTagId);//give all the conforming particles a unified sequence no.