#include "StdAfx.h"
|
#include "AssemDefect.h"
|
|
|
void CDefectBlob::CreateBlob(CDefectPair *pPair, int id)
|
{
|
ResetReuse();
|
|
CheckDefectRect(pPair->s_nDefectX, pPair->s_nDefectY);
|
s_sZonePixelCount[pPair->s_nZone] = 1;
|
//SetDefectPos(pPair->s_DefectPos);
|
s_DefectPos= pPair->s_DefectPos;
|
//SetDefectPair(pPair->s_DefectPair);
|
s_DefectPair= pPair->s_DefectPair;
|
s_nIndex = id;
|
s_nDefectArea = 1;
|
s_nPadRegionIdx = -1;
|
s_nDefectX = pPair->s_nDefectX;
|
s_nDefectY = pPair->s_nDefectY;
|
s_DefectType = pPair->s_DefectType; //½ÇÁ¦ ¹é°áÇÔÀº 1,Èæ°áÇÔÀº 0
|
s_sThreshold = pPair->s_nThresold;
|
s_nThresholdSum = pPair->s_nThresold;
|
// Gray ±¸Çϱâ
|
s_sLevelSrcMax = pPair->s_nGraySrc;
|
s_xLevelSrcMax = pPair->s_nDefectX;
|
s_yLevelSrcMax = pPair->s_nDefectY;
|
|
s_sLevelSrcMin = pPair->s_nGraySrc;
|
s_nLevelSrcSum = pPair->s_nGraySrc;
|
|
s_sLevelRefMax = pPair->s_nGrayRef;
|
s_sLevelRefMin = pPair->s_nGrayRef;
|
s_nLevelRefSum = pPair->s_nGrayRef;
|
|
int nDiffGray;
|
// nDiffGray= abs(7);
|
|
//BOE Float ¸ðµâ¿¡¼ Th¸¦ ¾È»©¼ ³ª¿Â´Ù.(Pixel, Zone Àº »©¼ ³ª¿È)
|
//nDiffGray= abs(pPair->s_fDefectPeak);//abs(pPair->s_nGraySrc - pPair->s_nGrayRef);
|
nDiffGray= pPair->s_fDefectPeak;
|
|
s_sLevelDiffMax = nDiffGray+ s_sThreshold;
|
s_sDefectPeak = nDiffGray;//abs(s_sLevelDiffMax) - nThres;
|
//s_sDefectPeak = abs(s_sLevelDiffMax / 8) - nThres;
|
s_xMaxPeak= pPair->s_nDefectX;
|
s_yMaxPeak= pPair->s_nDefectY;
|
|
s_sLevelDiffMin = nDiffGray+ s_sThreshold;
|
s_nLevelDiffSum = nDiffGray+ s_sThreshold;
|
s_sZoneValueMin[pPair->s_nZone] = s_sZoneValueMax[pPair->s_nZone] = s_sZoneValueSum[pPair->s_nZone] = nDiffGray;
|
}
|
|
void CDefectBlob::IncludePair(CDefectPair *pPair)
|
{
|
s_sZonePixelCount[pPair->s_nZone]++;
|
|
CheckDefectRect(pPair->s_nDefectX, pPair->s_nDefectY);
|
|
SetDefectPos(pPair->s_DefectPos);
|
SetDefectPair(pPair->s_DefectPair);
|
s_nDefectArea++;
|
s_nDefectX += pPair->s_nDefectX;
|
s_nDefectY += pPair->s_nDefectY;
|
int nThres= pPair->s_nThresold;
|
if (nThres > s_sThreshold)
|
s_sThreshold = nThres;
|
s_nThresholdSum += pPair->s_nThresold;
|
|
// Gray ±¸Çϱâ
|
if (pPair->s_nGraySrc > s_sLevelSrcMax)
|
{
|
s_sLevelSrcMax = pPair->s_nGraySrc;
|
s_xLevelSrcMax = pPair->s_nDefectX;
|
s_yLevelSrcMax = pPair->s_nDefectY;
|
}
|
if (pPair->s_nGraySrc < s_sLevelSrcMin)
|
s_sLevelSrcMin = pPair->s_nGraySrc;
|
s_nLevelSrcSum += pPair->s_nGraySrc;
|
|
if (pPair->s_nGrayRef > s_sLevelRefMax)
|
s_sLevelRefMax = pPair->s_nGrayRef;
|
if (pPair->s_nGrayRef < s_sLevelRefMin)
|
s_sLevelRefMin = pPair->s_nGrayRef;
|
s_nLevelRefSum += pPair->s_nGrayRef;
|
|
//BOE Float ¸ðµâ¿¡¼ Th¸¦ ¾È»©¼ ³ª¿Â´Ù.(Pixel, Zone Àº »©¼ ³ª¿È)
|
//int nDiffGray = abs(pPair->s_fDefectPeak);//abs(pPair->s_nGraySrc - pPair->s_nGrayRef);
|
int nDiffGray = pPair->s_fDefectPeak;
|
if (nDiffGray > s_sDefectPeak)
|
{
|
s_sLevelDiffMax = nDiffGray+ nThres;
|
s_sDefectPeak = nDiffGray;
|
s_xMaxPeak= pPair->s_nDefectX;
|
s_yMaxPeak= pPair->s_nDefectY;
|
//s_sDefectPeak = abs(s_sLevelDiffMax / 8) - nThres;
|
}
|
if (nDiffGray < s_sLevelDiffMin)
|
s_sLevelDiffMin = nDiffGray+ nThres;
|
s_nLevelDiffSum += (nDiffGray+ nThres);
|
|
s_sZoneValueMin[pPair->s_nZone] = min(s_sZoneValueMin[pPair->s_nZone],nDiffGray);
|
s_sZoneValueMax[pPair->s_nZone] = max(s_sZoneValueMax[pPair->s_nZone],nDiffGray);
|
s_sZoneValueSum[pPair->s_nZone] = (s_sZoneValueSum[pPair->s_nZone]+nDiffGray);
|
|
}
|
void CDefectBlob::CheckDefectRect(int nX, int nY)
|
{
|
if (nY <= s_DefectRect.top)
|
{
|
s_DefectRect.top = nY;
|
if (s_ptVertex[2].y == nY) // Top Left
|
{
|
if (nX < s_ptVertex[2].x)
|
{
|
s_ptVertex[2].x = nX;
|
s_ptVertex[2].y = nY;
|
}
|
}
|
else
|
{
|
s_ptVertex[2].x = nX;
|
s_ptVertex[2].y = nY;
|
}
|
if (s_ptVertex[3].y == nY) // Top Right
|
{
|
if (nX + 1 > s_ptVertex[3].x)
|
{
|
s_ptVertex[3].x = nX + 1;
|
s_ptVertex[3].y = nY;
|
}
|
}
|
else
|
{
|
s_ptVertex[3].x = nX + 1;
|
s_ptVertex[3].y = nY;
|
}
|
}
|
if (nY + 1 >= s_DefectRect.bottom)
|
{
|
s_DefectRect.bottom = nY + 1;
|
if (s_ptVertex[6].y == nY + 1) // Bottom Left
|
{
|
if (nX < s_ptVertex[6].x)
|
{
|
s_ptVertex[6].x = nX;
|
s_ptVertex[6].y = nY + 1;
|
}
|
}
|
else
|
{
|
s_ptVertex[6].x = nX;
|
s_ptVertex[6].y = nY + 1;
|
}
|
if (s_ptVertex[7].y == nY + 1) // Bottom Right
|
{
|
if (nX + 1 > s_ptVertex[7].x)
|
{
|
s_ptVertex[7].x = nX + 1;
|
s_ptVertex[7].y = nY + 1;
|
}
|
}
|
else
|
{
|
s_ptVertex[7].x = nX + 1;
|
s_ptVertex[7].y = nY + 1;
|
}
|
}
|
if (nX <= s_DefectRect.left)
|
{
|
s_DefectRect.left = nX;
|
if (s_ptVertex[1].x == nX) // Left Bottom
|
{
|
if (nY + 1 > s_ptVertex[1].y)
|
{
|
s_ptVertex[1].x = nX;
|
s_ptVertex[1].y = nY + 1;
|
}
|
}
|
else
|
{
|
s_ptVertex[1].x = nX;
|
s_ptVertex[1].y = nY + 1;
|
}
|
if (s_ptVertex[0].x == nX) // Left Top
|
{
|
if (nY < s_ptVertex[0].y)
|
{
|
s_ptVertex[0].x = nX;
|
s_ptVertex[0].y = nY;
|
}
|
}
|
else
|
{
|
s_ptVertex[0].x = nX;
|
s_ptVertex[0].y = nY;
|
}
|
}
|
if (nX + 1 >= s_DefectRect.right)
|
{
|
s_DefectRect.right = nX + 1;
|
if (s_ptVertex[5].x == nX + 1) // Right Bottom
|
{
|
if (nY + 1 > s_ptVertex[5].y)
|
{
|
s_ptVertex[5].x = nX + 1;
|
s_ptVertex[5].y = nY + 1;
|
}
|
}
|
else
|
{
|
s_ptVertex[5].x = nX + 1;
|
s_ptVertex[5].y = nY + 1;
|
}
|
if (s_ptVertex[4].x == nX + 1) // Right Top
|
{
|
if (nY < s_ptVertex[4].y)
|
{
|
s_ptVertex[4].x = nX + 1;
|
s_ptVertex[4].y = nY;
|
}
|
}
|
else
|
{
|
s_ptVertex[4].x = nX + 1;
|
s_ptVertex[4].y = nY;
|
}
|
}
|
}
|