瀏覽代碼

special gray particle recognize and diagnosis

gsp 3 年之前
父節點
當前提交
f2f13e504c

+ 63 - 20
OTSCPP/OTSImagePro/OTSImageProcess.cpp

@@ -1281,44 +1281,32 @@ namespace OTSIMGPROC
 
 		return TRUE;
 	}
-	BOOL COTSImageProcess::GetParticlesBySpecialGrayRange(CBSEImgPtr m_pBSEImg, CIntRangePtr a_grayRange, COTSFieldDataPtr m_pFieldData)
+	BOOL COTSImageProcess::GetParticlesBySpecialGrayRange(CBSEImgPtr a_pBSEImg, CIntRangePtr a_grayRange, COTSFieldDataPtr m_pFieldData)
 	{
 		ASSERT(m_pFieldData);
 
-		ASSERT(m_pBSEImg);
+		ASSERT(a_pBSEImg);
 
 		ASSERT(a_grayRange);
 
 
-		int nWidthImg = m_pBSEImg->GetWidth();
-		int nHeightImg = m_pBSEImg->GetHeight();
+		int nWidthImg = a_pBSEImg->GetWidth();
+		int nHeightImg = a_pBSEImg->GetHeight();
 		m_pFieldData->Width = nWidthImg;
 		m_pFieldData->Height = nHeightImg;
 		long nImgSize = nWidthImg * nHeightImg;
 
 
-		BYTE* pSrcImg = m_pBSEImg->GetImageDataPointer();
+		BYTE* pSrcImg = a_pBSEImg->GetImageDataPointer();
 
 		BYTE* pTempImg = new BYTE[nImgSize];
 
 
 		CBSEImgPtr imgNoBGBinary = CBSEImgPtr(new CBSEImg());
-		CBSEImgPtr imgNoBGBinary1 = CBSEImgPtr(new CBSEImg());
+		
 		long nNumParticle = 0;
-		COTSImageProcessParamPtr a_pImageProcessParam = COTSImageProcessParamPtr(new COTSImageProcessParam());
-		CIntRange lowRange ;
-		CIntRange highRange;
-		lowRange.SetStart(0);
-		lowRange.SetEnd(a_grayRange->GetStart());
-		highRange.SetStart(a_grayRange->GetEnd() + 1);
-		highRange.SetEnd(255);
-		a_pImageProcessParam->SetBGRemoveType((int)OTS_BGREMOVE_TYPE::MANUAL);
-		a_pImageProcessParam->SetBGGray(lowRange);
-		CIntRange partRange = CIntRange(0, 255);
-		a_pImageProcessParam->SetParticleGray(partRange);
-		RemoveBackGround(m_pBSEImg, a_pImageProcessParam, imgNoBGBinary1, nNumParticle);
-		a_pImageProcessParam->SetBGGray(highRange);
-		RemoveBackGround(imgNoBGBinary1, a_pImageProcessParam, imgNoBGBinary, nNumParticle);
+
+		GetSpecialGrayRangeImage(a_pBSEImg, a_grayRange, imgNoBGBinary, nNumParticle);
 
 
 
@@ -1527,6 +1515,61 @@ namespace OTSIMGPROC
 	
 		return pRangeFirst;
 	}
+	void COTSImageProcess::GetSpecialGrayRangeImage(CBSEImgPtr a_pImgIn, CIntRangePtr a_SpecialGrayRange, CBSEImgPtr a_pBinImgOut, long& foundedPixelNum)
+	{
+		// the background  pixel will be 0,and the other part will be 255.
+		ASSERT(a_pImgIn);
+
+
+	
+		int nWidthImg = a_pImgIn->GetWidth();
+		int nHeightImg = a_pImgIn->GetHeight();
+
+		long nImgSize = nWidthImg * nHeightImg;
+
+		BYTE* pTempImg = new BYTE[nImgSize];
+
+		BYTE* pSrcImg = a_pImgIn->GetImageDataPointer();
+
+
+		BYTE* pPixel = new byte[nImgSize];
+
+
+
+		long nBGStart;
+		long nBGEnd;
+	
+		long nNumParticle = 0;
+	
+			nBGStart = a_SpecialGrayRange->GetStart();
+			nBGEnd = a_SpecialGrayRange->GetEnd();
+			
+
+			// delete background 
+			for (unsigned int i = 0; i < nImgSize; i++)
+			{
+				if (pSrcImg[i] >= nBGStart && pSrcImg[i] <= nBGEnd)
+				{
+					pPixel[i] = 255;
+					nNumParticle++;
+				}
+				else
+				{
+					pPixel[i] = 0;
+					
+				}
+		
+			}
+			COTSImageProcess::BErode3(pPixel, pTempImg, 5, nHeightImg, nWidthImg);
+			COTSImageProcess::BDilate3(pTempImg, pPixel, 5, nHeightImg, nWidthImg);
+		
+		a_pBinImgOut->SetImageData(pPixel, nWidthImg, nHeightImg);
+
+		foundedPixelNum = nNumParticle;
+		delete[] pTempImg;
+
+		return;
+	}
 	void COTSImageProcess::RemoveBackGround(CBSEImgPtr a_pImgIn, COTSImageProcessParamPtr a_pImageProcessParam, CBSEImgPtr a_pBinImgOut,long& foundedPixelNum)
 	{
 		// the background  pixel will be 0,and the other part will be 255.

+ 1 - 0
OTSCPP/OTSImagePro/OTSImageProcess.h

@@ -67,6 +67,7 @@ namespace OTSIMGPROC {
 		static BOOL GetParticlesBySpecialGrayRange(CBSEImgPtr m_pBSEImg, CIntRangePtr a_grayRange, COTSFieldDataPtr m_pFieldData);
 
 		static CIntRangePtr CalBackground(CBSEImgPtr m_pBSEImg);
+		static void GetSpecialGrayRangeImage(CBSEImgPtr a_pImgIn, CIntRangePtr a_SpecialGrayRange, CBSEImgPtr a_pBinImgOut, long& foundedPixelNum);
 		static void RemoveBackGround(CBSEImgPtr a_pImgIn, COTSImageProcessParamPtr a_pImageProcessParam, CBSEImgPtr a_pImgOut,long& foundedPixelNum);
 		static BOOL CalcuParticleImagePropertes(COTSParticlePtr part, double a_PixelSize);
 

+ 4 - 4
OTSIncAMeasureApp/0-OTSModel/Measure/1-OTSInclution/SmplMeasureInclution.cs

@@ -356,13 +356,13 @@ namespace OTSModelSharp
         
             //save the xray data and element data.
             CPosXrayDBMgr PosXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
-            var m_listAnalysisPosXray = new List<CPosXrayClr>();
-            foreach (var p in curFldData.GetListAnalysisParticles())
+            var listAnalysisPosXray = new List<CPosXrayClr>();
+            foreach (var p in curFldData.GetListXrayParticles())
             {
-                m_listAnalysisPosXray.Add(p.GetXray());
+                listAnalysisPosXray.Add(p.GetXray());
             }
            
-            if (!PosXrayDBMgr.SaveXray(m_listAnalysisPosXray, true))
+            if (!PosXrayDBMgr.SaveXray(listAnalysisPosXray, true))
             {
                 log.Info("SaveFieldFiles: save analysis x-ray failed.");
                 return false;

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

@@ -174,7 +174,7 @@ namespace OTSModelSharp
             //int nGrayHigh = oParticleGrayRange.GetEnd();
             //-------------------------------------------
             // get particles list
-            List<COTSParticleClr> listParticles =m_listParticles;
+           
             // go through each particles
 
             int nTagId = 0;
@@ -182,8 +182,8 @@ namespace OTSModelSharp
             int tooSmallnum = 0;
          
             int overSizenum = 0;
-            log.Info("Total Particles: " + listParticles.Count);
-            foreach (COTSParticleClr pParticle in listParticles)
+            log.Info("Total Particles: " + m_listParticles.Count);
+            foreach (COTSParticleClr pParticle in m_listParticles)
             {
                 // get particle area 
                 double dPartArea = pParticle.GetArea();

+ 2 - 2
OTSIncAMeasureApp/0-OTSModel/Measure/DBDataTransition/IncADataDB.cs

@@ -41,7 +41,7 @@ namespace OTSModelSharp
             return ret;
         }
 
-        public bool SaveAIncA(COTSParticleClr a_pParticle, CPosXrayClr a_pXray, System.Drawing.Point fldPos)
+        public bool SaveAIncA(COTSParticleClr a_pParticle,  System.Drawing.Point fldPos)
         {
        
             var tableInfoPtr = GetTableInfo();
@@ -58,7 +58,7 @@ namespace OTSModelSharp
             Rectangle rec = (Rectangle)a_pParticle.GetParticleRect();
             System.Drawing.Point xrayPos = (System.Drawing.Point)a_pParticle.GetXRayPos();
             System.Drawing.Point semPos = (System.Drawing.Point)a_pParticle.GetAbsolutPos();
-            sSQLCommand =string.Format(sInsertFormat, a_pParticle.GetFieldId(), a_pParticle.GetAnalysisId(), a_pParticle.GetAveGray(), rec.Left, rec.Top, rec.Width, rec.Height, a_pParticle.GetArea(), xrayPos.X, xrayPos.Y, a_pParticle.GetClassifyId(), (int)a_pXray.GetElementQuantifyData().Count, (int)(a_pParticle.GetFeature().GetSegmentsList().Count), fldPos.X, fldPos.Y, a_pParticle.GetTagId(), a_pParticle.GetDMAX(), a_pParticle.GetDMIN(), a_pParticle.GetDMPERP(), a_pParticle.GetDPRIMETER(), a_pParticle.GetORIENTATION(), a_pParticle.GetDINSCR(), a_pParticle.GetDMEAN(), a_pParticle.GetDELONG(), a_pParticle.GetFeretDiameter(), a_pParticle.GetTypeName(), a_pParticle.GetTypeColor(),semPos.X,semPos.Y);
+            sSQLCommand =string.Format(sInsertFormat, a_pParticle.GetFieldId(), a_pParticle.GetAnalysisId(), a_pParticle.GetAveGray(), rec.Left, rec.Top, rec.Width, rec.Height, a_pParticle.GetArea(), xrayPos.X, xrayPos.Y, a_pParticle.GetClassifyId(), 0, (int)(a_pParticle.GetFeature().GetSegmentsList().Count), fldPos.X, fldPos.Y, a_pParticle.GetTagId(), a_pParticle.GetDMAX(), a_pParticle.GetDMIN(), a_pParticle.GetDMPERP(), a_pParticle.GetDPRIMETER(), a_pParticle.GetORIENTATION(), a_pParticle.GetDINSCR(), a_pParticle.GetDMEAN(), a_pParticle.GetDELONG(), a_pParticle.GetFeretDiameter(), a_pParticle.GetTypeName(), a_pParticle.GetTypeColor(),semPos.X,semPos.Y);
 
             if (!datastorePtr.RunCommand(sSQLCommand))
             {

+ 2 - 2
OTSIncAMeasureApp/0-OTSModel/Measure/DBDataTransition/IncAFileMgr.cs

@@ -263,10 +263,10 @@ namespace OTSModelSharp
             foreach (var pParticle in m_listParticle)
             {
               
-                CPosXrayClr pXrayPtr=pParticle.GetXray();
+                //CPosXrayClr pXrayPtr=pParticle.GetXray();
                 
 
-                if (!m_IncADataDB.SaveAIncA(pParticle, pXrayPtr, m_FieldPos))
+                if (!m_IncADataDB.SaveAIncA(pParticle,  m_FieldPos))
                 {
 
                         return false;

+ 8 - 7
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CreateRectangle.cs

@@ -984,19 +984,20 @@ namespace OTSMeasureApp
         //设置可视化灰度
         SetVisualGray = 1,
         //显示BSE灰度曲线图
-        grayToolStripMenuItem = 2,
+        SetVisualGrayForSpecialGray=2,
+        grayToolStripMenuItem =4,
         //切换至BSE图
-        ChangeDiffImageShow = 4,
+        ChangeDiffImageShow = 5,
         //BSE去背景图
-        DelBSEBG = 5,
+        DelBSEBG =6,
         //显示BSE去背景灰度曲线图
-        SampleHoleBSEImage = 6,
+        SampleHoleBSEImage = 7,
         //线扫描曲线
-        MenuItemLineScam = 8,
+        MenuItemLineScam = 9,
         //单点采集Xray与元素信息
-        PointScanElementMenuItem = 9,
+        PointScanElementMenuItem = 10,
         //导出采集信息报告
-        ExportReport =10
+        ExportReport =11
     }
 
     //public enum photoMode

+ 6 - 0
OTSIncAMeasureApp/7-OTSProgMgrInfo/ProgMgrInfoForm.cs

@@ -12,6 +12,7 @@ using static OTSModelSharp.ResourceManage.ResourceData;
 
 using static OTSDataType.otsdataconst;
 using OTSModelSharp.Measure.GetStageInfo;
+using OTSMeasureApp._0_OTSModel.Measure.ParamData;
 
 namespace OTSMeasureApp
 {
@@ -2022,6 +2023,11 @@ namespace OTSMeasureApp
         {
             ThisSetIsModify();
         }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            System.Diagnostics.Process.Start("notepad.exe",CSpecialGrayRangeParam.GetParamFileFullName());
+        }
     }
     public class ComboBoxItem
     {

File diff suppressed because it is too large
+ 266 - 173
OTSIncAMeasureApp/7-OTSProgMgrInfo/ProgMgrInfoForm.designer.cs


Some files were not shown because too many files changed in this diff