//20161221 µ¥¸ð¿ëÀ¸·Î ±ÞÇÏ°Ô ¸¸µë
|
//ÀÌÁøÈ °Ë»ç(¿§ÁöÅ©·¢°Ë»ç µî¿¡ ¾²ÀÚ)
|
#include "stdafx.h"
|
|
#include "BlobStorage.h"
|
#include <wmmintrin.h>
|
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#endif
|
|
#include "SISAssem.h"
|
#include "AssemParam.h"
|
|
int CSISAssem::BinalizeInspection(BYTE *pSrc, int nThresS, int nThresE, CRect rtROI
|
,int nWidth, CDefectPair *pDefectdPair, int nStartPair, int nMaxPair
|
,int &nEndLine)
|
{
|
int nPair = nStartPair;
|
CDefectPair* PairAddr = pDefectdPair + nPair;
|
|
if(nThresE < nThresS)
|
{
|
int nTemp = nThresS;
|
nThresS = nThresE;
|
nThresE = nTemp;
|
}
|
|
__m128i ZeroData = _mm_setzero_si128();
|
__m128i ThresHigh = _mm_set1_epi8(UCHAR(nThresE)^0x80);
|
__m128i ThresLow = _mm_set1_epi8(UCHAR(nThresS)^0x80);
|
__m128i OneAll = _mm_set1_epi8(-1);
|
__m128i Image;
|
__m128i Result;
|
__m128i Temp;
|
__m128i _x80 = _mm_set1_epi8('\x80');
|
|
BYTE *pS, *pS_;
|
|
int nx, ny;
|
int nStartX, nEndX, nStartY, nEndY;
|
nStartY = rtROI.top;
|
nEndY = nStartY + rtROI.Height();
|
nStartX = rtROI.left;
|
nEndX = rtROI.right-16;
|
|
pS = pSrc + nWidth * nStartY + nStartX;
|
|
for(ny = nStartY; ny < nEndY; ny++)
|
{
|
pS_ = pS;
|
for(nx = nStartX; nx < nEndX; nx+=16) //16°³¾¿ ó¸®
|
{
|
//À̹ÌÁöµ¥ÀÌÅÍ ·Îµù(src)
|
Image = _mm_loadu_si128((__m128i*) (pS_));
|
|
//Å«°Å
|
Temp = _mm_cmpgt_epi8(_mm_xor_si128(Image, _x80), ThresLow);
|
Result = _mm_cmplt_epi8(_mm_xor_si128(Image, _x80), ThresHigh);
|
Result = _mm_and_si128(Result, Temp);
|
|
if(_mm_movemask_epi8(Result) != 0)
|
{
|
for(int i = 0; i < 16; i++)
|
{
|
if(Result.m128i_i8[i] != 0)
|
{
|
PairAddr->s_DefectPos = DEFPOS_CENTER;
|
PairAddr->s_DefectPair = DEFPAIR_PPAIR;
|
PairAddr->s_nDefectX = nx + i;
|
PairAddr->s_nDefectY = ny;
|
PairAddr->s_DefectType = DEFTYPE_BLACK;
|
PairAddr->s_nGraySrc = Image.m128i_u8[i];
|
PairAddr->s_nGrayRef = nThresE;
|
PairAddr->s_nZone = 0;
|
PairAddr->s_nThresold = nThresE;
|
PairAddr++;
|
nPair++;
|
|
if(nPair >= nMaxPair)
|
{
|
nEndLine = ny;
|
return nPair;
|
}
|
}
|
}
|
}
|
pS_ += 16;
|
}
|
pS += nWidth;
|
}
|
|
/*
|
nEndX+=16;
|
for(ny = nStartY; ny < nEndY; ny++)
|
{
|
pS_ = pS;
|
for(; nx < nEndX; nx++) //16°³¾¿ ó¸®
|
{
|
if(*(pS_) > nThresS && *(pS_) < nThresE)
|
{
|
PairAddr->s_DefectPos = DEFPOS_CENTER;
|
PairAddr->s_DefectPair = DEFPAIR_PPAIR;
|
PairAddr->s_nDefectX = nx;
|
PairAddr->s_nDefectY = ny;
|
PairAddr->s_DefectType = DEFTYPE_BLACK;
|
PairAddr->s_nGraySrc = *(pS_);
|
PairAddr->s_nGrayRef = nThresE;
|
PairAddr->s_nZone = 0;
|
PairAddr->s_nThresold = nThresE;
|
PairAddr++;
|
nPair++;
|
|
if(nPair >= nMaxPair)
|
{
|
nEndLine = ny;
|
return nPair;
|
}
|
}
|
|
pS_ ++;
|
}
|
pS += nWidth;
|
}
|
*/
|
|
nEndLine = (int)rtROI.bottom;
|
return nPair;
|
}
|