Procházet zdrojové kódy

leverage the matrix points as seeds for the watershed algorithm

gsp před 7 měsíci
rodič
revize
a43b63a07a

+ 2 - 2
Bin/x64/Debug/Config/ProData/HardwareConfig.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <XMLData PathName="HardwareConfig.xml" ID="1">
-  <Member RegName="SemControllerName" Value="Oxford" ImageInputSources="SE" />
-  <Member RegName="EDSName" Value="Oxford" DelayQuantify="true" WeightPercentageToAtomicPercentage="false" />
+  <Member RegName="SemControllerName" Value="OffLine" ImageInputSources="SE" />
+  <Member RegName="EDSName" Value="OffLine" DelayQuantify="true" WeightPercentageToAtomicPercentage="false" />
   <Member RegName="BrukerDllVersion" Version="Bruker.API.Esprit64.dll" />
   <Member RegName="FEIIP" Value="192.168.0.1" />
   <Member RegName="FEIPORT" Value="7520" />

+ 56 - 16
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -456,29 +456,29 @@ namespace OTSIMGPROC
 
 
 		std::vector<CPoint> matrixPs;
+		GetMatrixPointsFromRect(rect, xrayStep, matrixPs);
+		//int colnum = ceil((double)rect.Width() / xrayStep + 0.5);
+		//if (colnum % 2 == 0) colnum += 1;//let the number to be an odd number.Then we can make the middle point in the center of the particle exactly.
+		//int rownum = ceil((double)rect.Height() / xrayStep + 0.5);
+		//if (rownum % 2 == 0) rownum += 1;
 
-		int colnum = ceil((double)rect.Width() / xrayStep + 0.5);
-		if (colnum % 2 == 0) colnum += 1;//let the number to be an odd number.Then we can make the middle point in the center of the particle exactly.
-		int rownum = ceil((double)rect.Height() / xrayStep + 0.5);
-		if (rownum % 2 == 0) rownum += 1;
+		//CPoint theFirst = CPoint(rect.left - (colnum * xrayStep - rect.Width()) / 2 + xrayStep / 2, rect.top - (rownum * xrayStep - rect.Height()) / 2 + xrayStep / 2);
 
-		CPoint theFirst = CPoint(rect.left - (colnum * xrayStep - rect.Width()) / 2 + xrayStep / 2, rect.top - (rownum * xrayStep - rect.Height()) / 2 + xrayStep / 2);
 
+		//for (int i = 0; i < rownum; i++)
+		//{
+		//	for (int j = 0; j < colnum; j++)
+		//	{
+		//		double x = (double)theFirst.x + (double)j * xrayStep;
+		//		double y = (double)theFirst.y + (double)i * xrayStep;
+		//		CPoint thePoint = CPoint(x, y);
 
-		for (int i = 0; i < rownum; i++)
-		{
-			for (int j = 0; j < colnum; j++)
-			{
-				double x = (double)theFirst.x + (double)j * xrayStep;
-				double y = (double)theFirst.y + (double)i * xrayStep;
-				CPoint thePoint = CPoint(x, y);
 
+		//		matrixPs.push_back(thePoint);
 
-				matrixPs.push_back(thePoint);
 
-
-			}
-		}		
+		//	}
+		//}		
 		int i = 0;
 		COTSParticleList matrixParts;
 		for (auto point : matrixPs)
@@ -559,6 +559,16 @@ namespace OTSIMGPROC
 		std::vector<CPoint> seeds;
 		seeds.clear();
 		FindSeedsByGrayScale(noBgImg, a_PixelSize, seeds);
+		std::vector<CPoint> matrixseeds;
+		matrixseeds.clear();
+		if (seeds.size() <20)
+		{
+			auto step = areaRng.GetStart() * 4;
+			GetMatrixPointsFromRect(fieldImg->GetImageRect(), step / a_PixelSize, matrixseeds);
+			seeds.insert(seeds.end(), matrixseeds.begin(), matrixseeds.end());
+		}
+		
+		
 
 		Mat matImg = GetMatDataFromBseImg(noBgImg);
 
@@ -1644,6 +1654,36 @@ namespace OTSIMGPROC
 
 
 
+		return true;
+	}
+
+	BOOL COTSImageProcess::GetMatrixPointsFromRect(CRect rect, double xrayStep, std::vector<CPoint>& matrixPs)
+	{
+		int colnum = ceil((double)rect.Width() / xrayStep + 0.5);
+		if (colnum % 2 == 0) colnum += 1;//let the number to be an odd number.Then we can make the middle point in the center of the particle exactly.
+		int rownum = ceil((double)rect.Height() / xrayStep + 0.5);
+		if (rownum % 2 == 0) rownum += 1;
+
+		CPoint theFirst = CPoint(rect.left - (colnum * xrayStep - rect.Width()) / 2 + xrayStep / 2, rect.top - (rownum * xrayStep - rect.Height()) / 2 + xrayStep / 2);
+
+
+		for (int i = 0; i < rownum; i++)
+		{
+			for (int j = 0; j < colnum; j++)
+			{
+				double x = (double)theFirst.x + (double)j * xrayStep;
+				double y = (double)theFirst.y + (double)i * xrayStep;
+				CPoint thePoint = CPoint(x, y);
+
+				if (rect.PtInRect(thePoint))
+				{
+					matrixPs.push_back(thePoint);	
+				}
+				
+
+
+			}
+		}
 		return true;
 	}
 	

+ 1 - 1
OTSCPP/OTSImagePro/OTSImageProcess.h

@@ -42,7 +42,7 @@ namespace OTSIMGPROC {
 		 //void findPeakAndValley(const vector<int>& v, vector<int>& peakPositions, vector<int>& valleyPositions, int minPeakDistance);
 		 std::vector<CIntRange> GetValidGreyLevelRanges(CBSEImgPtr pBSEImg);
 		 BOOL FindSeedsByGrayScale(CBSEImgPtr fieldImg, double a_PixelSize, std::vector<CPoint>& OutSeeds);
-		
+		 BOOL GetMatrixPointsFromRect(CRect rect, double xrayStep, std::vector<CPoint>& matrixPs);
 		 void ImshowImage(CBSEImgPtr img);
 		 void ImshowChartData(CBSEImgPtr img);