// PixMatrix.h: interface for the CPixMatrix class. // 1.2.0.13. replace the AutoBadPointDec function ////////////////////////////////////////////////////////////////////// #if !defined(AFX_PIXMATRIX_H__A66061E3_ED45_4A21_ADDC_3A5F78FB36CE__INCLUDED_) #define AFX_PIXMATRIX_H__A66061E3_ED45_4A21_ADDC_3A5F78FB36CE__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 //#include "globle.h" #define NEIGHBOR_0 0x80000000L #define NEIGHBOR_1 0x40000000L #define NEIGHBOR_2 0x20000000L #define NEIGHBOR_3 0x10000000L #define NEIGHBOR_4 0x08000000L #define NEIGHBOR_5 0x04000000L #define NEIGHBOR_6 0x02000000L #define NEIGHBOR_7 0x01000000L /* #define MAX_BAD_PIXELS 200000L #define MAXI_BADPIX_COUNT 400000 // Big enough for the worst panel #define MAX_PIX_MAP_LINE 40000 #define OFFSET_MASK 0xFFFF */ #define MAX_BAD_PIXELS 1000000L #define MAXI_BADPIX_COUNT 400000 // Big enough for the worst panel #define MAX_PIX_MAP_LINE 40000 #define OFFSET_MASK 0xFFFF //code begin 20100906 typedef unsigned short ushort_t; //code end 20100906 // Single bad pixel entry typedef struct { long num_entries; long *bad_pixel_num; } BAD_PIXEL_ENTRY; // Pointer to a single bad pixel entry typedef BAD_PIXEL_ENTRY *BAD_PIXEL_ENTRY_PTR; // Bad pixels contained within a single line typedef struct pix_map { long len; long *p_Pix; } PIX_MAP; //BadLine typedef struct line_map { WORD line_entries; BOOL lLine; BOOL rLine; WORD startpoint; WORD endpoint; line_map * nextline; } LINE_MAP; //BadLine2 typedef struct line_map2 { int nLineType; int line_entries; int startpoint; int endpoint; line_map2 * nextline; } LINE_MAP2; class CPixMatrix { public: static CPixMatrix* Instance(); virtual ~CPixMatrix(); void CorrectBadPixels(WORD *image); void CorrectDBadLines(WORD *image); int CalSpecX(WORD* image); int CalSpecY(WORD* image); void SwitchDBadLines(WORD *image); void CorrectDXLines(WORD *image, int nentry, int nstart, int nend); void SwitchDXLines(WORD *image, int nentry, int nstart, int nend, int spec); void CorrectDYLines(WORD *image, int nentry, int nstart, int nend); void SwitchDYLines(WORD *image, int nentry, int nstart, int nend, int spec); void MarkBadAdjacentPixels(); void MarkBadPixels(int NumLines, PIX_MAP *New_Map); bool LoadBadPixelMap( const char *fileName ); bool LoadLineMap( const char *fileName ); bool LoadDLineMap( const char *fileName ); bool MarkAdjacentLine( LINE_MAP *m_linemap); void CorrectLines(WORD* image); bool FreeLineMap(LINE_MAP *m_linemap); bool LoadBadPixelMapChar(char* data_char, bool bNew = FALSE); bool SaveBadPixelMap(const char *fileName); int SaveBadLineMap(const char *fileName);//自动坏线标记 by chen G N 2013-01-16 void BadLineRecognize();//自动坏线标记 by chen G N 2013-01-23 int LoadandCorrectBadLine( unsigned short *pImage, int GridDirection );//坏线的二次校正 by chen G N 2013-01-16 bool AutoBadPixelMap(WORD *wImage); bool AutoBadPixelMap1(WORD *wImage); bool AutoBadPixelMap2(WORD *wImage); bool AutoBadPixelFixed(WORD *wImage, int threshold); void FreeBadPixelMap(); void FreeDBadLineMap(); void FreeBadNewPixelMap(); bool CombineBadPixelMap(); CPixMatrix(int width, int height,int woffset = 0, int hoffset = 0, int nPixelMax = 16383); void BeginAutoBadPixels(); //开始自动坏点校正 void AddImageforBadPixels(WORD *wImage); //输入图像用于自动坏点校正 bool AutoBadPointDec(unsigned short* lpDetail,int lWidth, int lHeight ,int Xoffset, int Yoffset,unsigned short*pmap); int GetAvg(unsigned short* pData,int Width, int Height ,int Xoffset, int Yoffset,int length); void EndAutoBadPixels(int nMode); //结束自动换点校正,-1,放弃;0,替换原有map;1,合并原有map void StoreBadPixels(const char * charFilename,int nMode); void CorrectButCross(WORD* image); WORD *m_mapImg; //WORD *m_curImg;////////////////////////chenGN 2013.01.31 //WORD *m_lastImg;////////////////////////chenGN 2013.01.31 int m_curAvg; int m_lastAvg; int m_nLineData;//m_nLineData »µÏß×î´ó¶ÎÊý, zhaoyiru, 2017.05.09 int *m_datalen; int Mean7(ushort_t *pImgData, int nWidth, int nHeight, int nXOffset, int nYOffset); double CalcGlbAvgPxlValueBySamp(unsigned short* pImgData, int nWidth, int nHeight, int nXOffset, int nYOffset); bool DetBadPxlByMF(ushort_t *pImgData, int nWidth, int nHeight, int nXOffset, int nYOffset, ushort_t *pMap); int BadGridLineCorrect( unsigned short *pImage); int BadGridLineCorrect1( unsigned short *pImage, int nLineDirection, int nEntries, int nStartPoint, int nEndPoint, int nWidth, int nHeight); int BadGridLineCorrect2( unsigned short *pImage, int nLineDirection, int nEntries, int nStartPoint, int nEndPoint, int nWidth, int nHeight); int BadGridLineCorrect3( unsigned short *pImage, int nLineDirection, int nEntries, int nStartPoint, int nEndPoint, int nWidth, int nHeight); int BadGridLineCorrect4( unsigned short *pImage, int nLineDirection, int nEntries, int nStartPoint, int nEndPoint, int nWidth, int nHeight); //bool CPixMatrix::DetBadPxlByMF(ushort_t *pImgData, int nWidth, int nHeight, int nXOffset, int nYOffset, ushort_t *pMap); private: static CPixMatrix* m_instance; PIX_MAP *m_NewMap; BAD_PIXEL_ENTRY *m_BadPixelMap; BAD_PIXEL_ENTRY *m_BadNewPixelMap; //store anothre badpixelmap, to combine with m_BadPixelMap; LINE_MAP *m_xLineMap; LINE_MAP *m_yLineMap; LINE_MAP2 *m_doubleLineMap; long *m_BadPixArray; int m_nWidth; int m_nHeight; int m_nWOffset; int m_nHOffset; int m_nLinePoint;//»µÏß×îСµãÊý, zhaoyiru, 2017.05.09 char m_charFilename[256]; unsigned short *m_TempImage; unsigned short *m_TempImage1; //int nWidth; //int nHeight; long *m_pBadPixNum; //int *m_datalen; int m_nPixelMax;//record the max pxiel value, for indicate the image pixel depth 16383, 65535 }; #endif // !defined(AFX_PIXMATRIX_H__A66061E3_ED45_4A21_ADDC_3A5F78FB36CE__INCLUDED_)