#include "StdAfx.h"
|
#include "ZoneReference.h"
|
|
#include "MosisAssem/AsseMutil.h"
|
#include "MosisStorage.h"
|
|
#include "TempRecipe.h"
|
|
|
|
//#define MOSIS_DEBUG_HMCONFIG
|
#if defined(MOSIS_DEBUG_HMCONFIG)
|
#include "HMConfigFile.h"
|
#endif
|
|
|
// Zone Threshold¸¦ °¨¸¶Å×À̺í·Î °Ë»çÇÑ´Ù. ÃÖÁ¾ Zoneº° Dynamic Threshold Àû¿ë - ZoneÀ̹ÌÁö(Image- Zone Index - Threshold - Add Threshold)
|
#define MOSIS_GAMMA_DTH // Dyanmic Threshold¸¦ ¾²Áö ¾ÊÀ» °æ¿ì undefÇØ¼ ¾µ ¼ö ÀÖÀ½.
|
#define TSP_ZONE_SIZE_OFFSET 20 // ÃÖÁ¾ Á¸ Å×À̺í À̹ÌÁö¿¡ ¿©ºÐÀ» µÒ.
|
|
CZoneReference::CZoneReference(void)
|
{
|
Reset_ZoneReference();
|
m_nZoneBaseThresFrist = m_nZoneBaseThresSecond = 0;
|
m_ZoneType= ZTYPE_DTH;
|
}
|
|
CZoneReference::~CZoneReference(void)
|
{
|
}
|
|
|
BOOL CZoneReference::Load_ZoneCfgFile(CString fileName)
|
{
|
return FALSE; //mch
|
|
/*
|
int strlength= fileName.GetLength();
|
if(strlength < 1)
|
return FALSE;
|
|
char *pResultFileThs = new char[strlength+1];
|
|
memset(pResultFileThs,0x00, sizeof(char)*strlength+1);
|
|
strcpy(pResultFileThs, fileName.LockBuffer());
|
|
pResultFileThs[fileName.GetLength()- 1] = 'g';
|
pResultFileThs[fileName.GetLength()- 2] = 'f';
|
pResultFileThs[fileName.GetLength()- 3] = 'c';
|
pResultFileThs[fileName.GetLength()- 4] = '.';
|
|
CHMConfigFile fileaccess;
|
fileaccess.SetFileName(pResultFileThs);
|
|
|
CString strCutOffValue = _T("");
|
int nZoneCutoff = 0;
|
|
#define MAX_ZONE_NUM 16
|
|
|
int i;
|
for( i = 0 ; i < MAX_ZONE_NUM-1; i++)
|
{
|
strCutOffValue.Format("LAYER_CUT_OFF_%d",i);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 0);
|
m_nZoneCutoffBlack[i+1] = nZoneCutoff;
|
|
strCutOffValue.Format("LAYER_CUT_OFF_WHITE_%d",i);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 0);
|
m_nZoneCutoffWhite[i+1] = nZoneCutoff;
|
}
|
|
strCutOffValue.Format("LAYER_CUT_OFF_%d",15);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 0);
|
m_nZoneCutoffBlack[0] = nZoneCutoff;
|
strCutOffValue.Format("LAYER_CUT_OFF_WHITE_%d",15);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 0);
|
m_nZoneCutoffWhite[0] = nZoneCutoff;
|
|
for(i= 0; i < MAX_ZONE_NUM-1; i++)
|
{
|
strCutOffValue.Format("LAYER_BLACK_THRES_%d", i);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 12);
|
m_nBlackThres[i+1]= nZoneCutoff;
|
strCutOffValue.Format("LAYER_BLACK_THRES2_%d", i);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 3);
|
//Zone Th Add +1
|
m_nBlackThres2[i+1]= nZoneCutoff+1;
|
|
strCutOffValue.Format("LAYER_WHITE_THRES_%d", i);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 12);
|
m_nWhiteThres[i+1]= nZoneCutoff;
|
strCutOffValue.Format("LAYER_WHITE_THRES2_%d", i);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 3);
|
//Zone Th Add +1
|
m_nWhiteThres2[i+1]= nZoneCutoff+1;
|
}
|
|
strCutOffValue.Format("LAYER_BLACK_THRES_%d",15);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 12);
|
m_nBlackThres[0] = nZoneCutoff;
|
strCutOffValue.Format("LAYER_BLACK_THRES2_%d",15);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 3);
|
//Zone Th Add +1
|
m_nBlackThres2[0] = nZoneCutoff+1;
|
|
strCutOffValue.Format("LAYER_WHITE_THRES_%d",15);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 12);
|
m_nWhiteThres[0] = nZoneCutoff;
|
strCutOffValue.Format("LAYER_WHITE_THRES2_%d",15);
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, nZoneCutoff, 3);
|
//Zone Th Add +1
|
m_nWhiteThres2[0] = nZoneCutoff+1;
|
|
strCutOffValue.Format("TSP_ZONE_OFFSET_X");
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, m_nZoneOffsetX, 0);
|
|
strCutOffValue.Format("TSP_ZONE_OFFSET_Y");
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, m_nZoneOffsetY, 0);
|
|
strCutOffValue.Format("LAYER_0");
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, m_nZoneBaseThresFrist, 0);
|
|
strCutOffValue.Format("LAYER2_0");
|
fileaccess.GetItemValue((LPSTR)(LPCTSTR)strCutOffValue, m_nZoneBaseThresSecond, 0);
|
|
//#define MOSIS_DEBUG_ZONE_CFG_TEMP
|
#ifdef MOSIS_DEBUG_ZONE_CFG_TEMP
|
nZoneCutoff= m_nZoneCutoff[MAX_ZONE_NUM-1];
|
for(i= 0; i< MAX_ZONE_NUM-1; i++)
|
{
|
m_nZoneCutoff[i+1]= m_nZoneCutoff[i];
|
}
|
m_nZoneCutoff[0]= nZoneCutoff;
|
#endif
|
|
|
delete pResultFileThs;
|
|
*/
|
|
return TRUE;
|
}
|
|
BOOL CZoneReference::Is_CutoffAfterShiftHigher(short *pZoneCount)
|
{
|
int iZone, i;
|
|
for(iZone= 15; iZone >= 0; iZone--)
|
{
|
if(pZoneCount[iZone] > 0)
|
break;
|
}
|
for(i= iZone- 1; i >= 0; i--)
|
{
|
pZoneCount[iZone]+= pZoneCount[i];
|
pZoneCount[i]= 0;
|
}
|
|
if(pZoneCount[iZone] > m_nZoneCutoffBlack[iZone])
|
return FALSE;
|
return TRUE;
|
}
|
|
BOOL CZoneReference::Is_Cutoff(short* zoneCounts, DefectType type)
|
{
|
if(type == DEFTYPE_WHITE)
|
return Is_Cutoff(zoneCounts, m_nZoneCutoffWhite);
|
return Is_Cutoff(zoneCounts, m_nZoneCutoffBlack);
|
}
|
|
BOOL CZoneReference::Is_Cutoff(short* zoneCounts, int *pZoneCutoff)//, int BlackWhite)
|
{// cutoff Ä«¿îÆ®¸¦ Çϳª¶óµµ ³Ñ´Â defectÀÌ ÀÖÀ¸¸é cut off ´ë»óÀÌ ¾Æ´Ï´Ù.
|
for(int i= 0;i<MAX_ZONE_NUM;i++)
|
{
|
if(zoneCounts[i] > pZoneCutoff[i])
|
{
|
return FALSE;
|
}
|
}
|
return TRUE;
|
}
|
|
void CZoneReference::ChangeZoneTh(int iZone, int nTh, int nSlide, int nCutoffBlack, int nCutoffWhite)
|
{
|
int x, y;
|
int yEnd;
|
|
if(nTh < 1)
|
nTh= 1;
|
|
if(nTh >= 255)
|
{
|
nTh= 255;
|
nSlide= 0;
|
}
|
|
if(nSlide < 0)
|
nSlide= 0;
|
if(nTh + nSlide > 255)
|
nSlide= 255- nTh;
|
|
yEnd= m_RectZone.Height();//m_ReferenceBuff.GetHeight();
|
for(y= 0; y< yEnd; y++)
|
{
|
for(x= 0; x< m_ZoneBuff.GetWidth(); x++)
|
{
|
if(m_ZoneBuff.GetPixel(x, y) == iZone)
|
{
|
m_ZoneThBuff.SetPixel(x, y, nTh);
|
m_ZoneAddBuff.SetPixel(x, y, nSlide);
|
// m_ZoneThBuff2.SetPixel(x, y, nTh);
|
// m_ZoneAddBuff2.SetPixel(x, y, nSlide);
|
}
|
}
|
}
|
|
m_nZoneCutoffBlack[iZone]= nCutoffBlack;
|
m_nZoneCutoffWhite[iZone]= nCutoffWhite;
|
}
|
|
BOOL CZoneReference::MakeZoneBuffer()
|
{// ÀÌ°Ç ´õÀÌ»ó ¾²Áö ¾Ê´Â´Ù.
|
int width, height;
|
width= m_ReferenceBuff.GetWidth()/2;
|
height= m_ReferenceBuff.GetHeight()/3;
|
|
m_RectPtrn.SetRect(0, 0, width, height);
|
if(! m_bForwardScan)
|
{
|
m_RectPtrn.OffsetRect(width, 0);
|
}
|
|
m_RectZone= m_RectPtrn;
|
m_RectZone.OffsetRect(0, height);
|
m_RectZoneTh= m_RectZone;
|
m_RectZoneTh.OffsetRect(0, height);
|
|
m_TemplBuff.SetSize(width, height);
|
m_ZoneBuff.SetSize(width, height);
|
m_ZoneThBuff.SetSize(width, height);
|
|
CMosisBuffer::CopyBtoA(m_TemplBuff, 0, 0, m_ReferenceBuff, m_RectPtrn);
|
CMosisBuffer::CopyBtoA(m_ZoneBuff, 0, 0, m_ReferenceBuff, m_RectZone);
|
CMosisBuffer::CopyBtoA(m_ZoneThBuff, 0, 0, m_ReferenceBuff, m_RectZoneTh);
|
|
return TRUE;
|
}
|
|
BOOL CZoneReference::MakeZoneBuffer_DTh()
|
{
|
int width, height;
|
width= m_ReferenceBuff.GetWidth()/2;
|
height= m_ReferenceBuff.GetHeight()/4;
|
|
|
m_RectPtrn.SetRect(0, 0, width, height);
|
if(! m_bForwardScan)
|
{
|
m_RectPtrn.OffsetRect(width, 0);
|
}
|
|
m_RectZone= m_RectPtrn;
|
m_RectZone.OffsetRect(0, height);
|
m_RectZoneTh= m_RectPtrn;
|
m_RectZoneTh.OffsetRect(0, height*2);
|
m_RectZoneAdd = m_RectPtrn;
|
m_RectZoneAdd.OffsetRect(0, height*3);
|
|
m_TemplBuff.SetSize(width, height);
|
m_ZoneBuff.SetSize(width, height);
|
m_ZoneThBuff.SetSize(width, height);
|
m_ZoneAddBuff.SetSize(width, height);
|
|
CMosisBuffer::CopyBtoA(m_TemplBuff, 0, 0, m_ReferenceBuff, m_RectPtrn);
|
CMosisBuffer::CopyBtoA(m_ZoneBuff, 0, 0, m_ReferenceBuff, m_RectZone);
|
CMosisBuffer::CopyBtoA(m_ZoneThBuff, 0, 0, m_ReferenceBuff, m_RectZoneTh);
|
CMosisBuffer::CopyBtoA(m_ZoneAddBuff, 0, 0, m_ReferenceBuff, m_RectZoneAdd);
|
|
return TRUE;
|
}
|
|
BOOL CZoneReference::MakeZoneBuffer_MPch()
|
{
|
int width, height;
|
width= m_ReferenceBuff.GetWidth()/2;
|
height= m_ReferenceBuff.GetHeight()/4;
|
|
m_RectPtrn.SetRect(0, 0, width, height);
|
if(! m_bForwardScan)
|
{
|
m_RectPtrn.OffsetRect(width, 0);
|
}
|
|
|
m_RectZone= m_RectPtrn;
|
m_RectZone.OffsetRect(0, height);
|
m_RectZoneTh= m_RectPtrn;
|
m_RectZoneTh.OffsetRect(0, height*2);
|
m_RectZoneAdd = m_RectPtrn;
|
m_RectZoneAdd.OffsetRect(0, height*3);
|
|
m_TemplBuff.SetSize(width, height);
|
m_ZoneBuff.SetSize(width, height);
|
m_ZoneThBuff.SetSize(width, height);
|
m_ZoneAddBuff.SetSize(width, height);
|
m_ZoneThBuff2.SetSize(width, height);
|
m_ZoneAddBuff2.SetSize(width, height);
|
|
CMosisBuffer::CopyBtoA(m_TemplBuff, 0, 0, m_ReferenceBuff, m_RectPtrn);
|
CMosisBuffer::CopyBtoA(m_ZoneBuff, 0, 0, m_ReferenceBuff, m_RectZone);
|
CMosisBuffer::CopyBtoA(m_ZoneThBuff, 0, 0, m_ReferenceBuff, m_RectZoneTh);
|
CMosisBuffer::CopyBtoA(m_ZoneAddBuff, 0, 0, m_ReferenceBuff, m_RectZoneAdd);
|
CMosisBuffer::CopyBtoA(m_ZoneThBuff2, 0, 0, m_ReferenceBuff, m_RectZoneTh);
|
CMosisBuffer::CopyBtoA(m_ZoneAddBuff2, 0, 0, m_ReferenceBuff, m_RectZoneAdd);
|
|
return TRUE;
|
}
|
|
BOOL CZoneReference::MakeZoneBuffer_MTh()
|
{
|
int width, height;
|
width= m_ReferenceBuff.GetWidth()/2;
|
height= m_ReferenceBuff.GetHeight()/7;
|
m_RectPtrn.SetRect(0, 0, width, height);
|
|
if(! m_bForwardScan)
|
{
|
m_RectPtrn.OffsetRect(width, 0);
|
}
|
|
m_RectZone= m_RectPtrn;
|
m_RectZone.OffsetRect(0, height);
|
m_RectZoneTh= m_RectPtrn;
|
m_RectZoneTh.OffsetRect(0, height*2);
|
m_RectZoneAdd = m_RectPtrn;
|
m_RectZoneAdd.OffsetRect(0, height*3);
|
m_RectZoneMMin= m_RectPtrn;
|
m_RectZoneMMin.OffsetRect(0, height*4);
|
m_RectZoneMTh= m_RectPtrn;
|
m_RectZoneMTh.OffsetRect(0, height*5);
|
m_RectZoneMAdd= m_RectPtrn;
|
m_RectZoneMAdd.OffsetRect(0, height*6);
|
|
m_TemplBuff.SetSize(width, height);
|
m_ZoneBuff.SetSize(width, height);
|
m_ZoneThBuff.SetSize(width, height);
|
m_ZoneAddBuff.SetSize(width, height);
|
m_ZoneMMinBuff.SetSize(width, height);
|
m_ZoneMThBuff.SetSize(width, height);
|
m_ZoneMAddBuff.SetSize(width, height);
|
|
CMosisBuffer::CopyBtoA(m_TemplBuff, 0, 0, m_ReferenceBuff, m_RectPtrn);
|
CMosisBuffer::CopyBtoA(m_ZoneBuff, 0, 0, m_ReferenceBuff, m_RectZone);
|
CMosisBuffer::CopyBtoA(m_ZoneThBuff, 0, 0, m_ReferenceBuff, m_RectZoneTh);
|
CMosisBuffer::CopyBtoA(m_ZoneAddBuff, 0, 0, m_ReferenceBuff, m_RectZoneAdd);
|
CMosisBuffer::CopyBtoA(m_ZoneMMinBuff, 0, 0, m_ReferenceBuff, m_RectZoneMMin);
|
CMosisBuffer::CopyBtoA(m_ZoneMThBuff, 0, 0, m_ReferenceBuff, m_RectZoneMTh);
|
CMosisBuffer::CopyBtoA(m_ZoneMAddBuff, 0, 0, m_ReferenceBuff, m_RectZoneMAdd);
|
|
return TRUE;
|
}
|
|
BOOL CZoneReference::Load_ZoneReference(CString &fileName, int iScan, BOOL bForwardScan, int frameWidth, int frameHeight, CString &panelid)
|
{
|
m_bForwardScan= bForwardScan;
|
m_iScan= iScan;
|
m_strHPanelID= panelid;
|
m_FrameWidth= frameWidth;
|
m_FrameHeight= frameHeight;
|
|
m_bReferenceLoaded = TRUE;
|
//m_bReferenceLoaded= m_ReferenceBuff.ReadFromFile(fileName);// 4byte ¾ó¶óÀÎ ¶§¹®¿¡. Á÷Á¢ ·ÎµùÇØ¾ß ÇÔ.
|
|
return m_bReferenceLoaded;
|
}
|