⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 histogram.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		{			rcPoint.left   = pOTFPolygon->nPointPiX[k] - HGSZ_HITTEST;			rcPoint.right  = pOTFPolygon->nPointPiX[k] + HGSZ_HITTEST;			rcPoint.top    = pOTFPolygon->nPointPiY[k] - HGSZ_HITTEST;			rcPoint.bottom = pOTFPolygon->nPointPiY[k] + HGSZ_HITTEST;			DrawFillRect(pDC, rcPoint, pOTFPolygon->crPoint[k]);		}		pDC->SelectObject(pOldPen);		pen.DeleteObject();	}}void RxHistogram::DrawSpectrum(CDC *pDC, CRect rect){	int		nOTFCount = m_ArrayOTFPolygon.GetSize();	if(nOTFCount <= 0)			return;	// 拳搁惑俊 焊捞绰 何盒	int		nPoBegin, nPoEnd, nPiBegin, nPiEnd, nPiWidth;	nPoBegin = max(m_stScroll.nRangeMinIn, m_stScroll.nPoMin);	nPoEnd   = min(m_stScroll.nRangeMaxIn, m_stScroll.nPoMax);	nPiBegin = PoToPiH(nPoBegin, m_stScroll.nPoMin, m_stScroll.nPoMax);	nPiEnd   = PoToPiH(nPoEnd,   m_stScroll.nPoMin, m_stScroll.nPoMax);	nPiWidth = nPiEnd - nPiBegin;	RxDib dib(CSize(nPiWidth, 1), 32);	unsigned int *lpColor = new unsigned int[nPiWidth];	// 茄 pixel寸 绢蠢沥档狼 CT interval俊 秦寸窍绰瘤..	float	fIncrease = (float)(nPoEnd - nPoBegin)/(float)(nPiEnd-nPiBegin); 	// 泅犁 困摹甫 0 Base, 硅凯 牢郸胶肺 函券茄促.	int		nIndex;	float	fIndex = (float)(nPoBegin - m_stScroll.nRangeMinIn);	for(int nPixel = nPiBegin; nPixel < nPiEnd; nPixel++)	{		nIndex = (int)(fIndex + 0.5f);		if(nIndex >= 0 && nIndex < m_stHistogram.nSize)			lpColor[nPixel-nPiBegin] = m_SpectrumTable.GetDIBColor(nIndex);		else			lpColor[nPixel-nPiBegin] = 0;		fIndex += fIncrease;	}	::StretchDIBits(pDC->GetSafeHdc(), nPiBegin, rect.top, nPiWidth, rect.Height(),		0, 0, nPiWidth, 1, lpColor, (LPBITMAPINFO)(dib.m_lpBmih), DIB_RGB_COLORS, SRCCOPY);	delete []lpColor;}/////////////////////////////////////////////////////////////////////////////// Calculate pixel, position functionsvoid RxHistogram::OnSize(UINT nType, int cx, int cy) {	CWnd::OnSize(nType, cx, cy);		m_szWindow.cx = cx;			m_szWindow.cy = cy;	RecalcScroll();	RecalcOTFPolygon();}// histogram width俊 措茄 coordnate conversionint  RxHistogram::PoToPiH(int nPos, int nPosRangeMin, int nPosRangeMax, BOOL bFitTail){	float	fRatio = (float)(m_szWindow.cx) / (float)(nPosRangeMax - nPosRangeMin);	int		nPixel;	if(bFitTail)	{		if(nPos >= nPosRangeMax)		nPixel = m_szWindow.cx;		else if(nPos <= nPosRangeMin)	nPixel = 0;		else							nPixel = (int)((nPos - nPosRangeMin) * fRatio + 0.5f);	}	else		nPixel = (int)((nPos - nPosRangeMin) * fRatio + 0.5f);	return nPixel;}int  RxHistogram::PiToPoH(int nPixel, int nPosRangeMin, int nPosRangeMax, BOOL bFitTail){	float	fRatio = (float)(nPosRangeMax - nPosRangeMin) / (float)(m_szWindow.cx);	int		nPos;		if(bFitTail)	{		if(nPixel >= m_szWindow.cx)	nPos = nPosRangeMax;		else if(nPixel <= 0)			nPos = nPosRangeMin;		else							nPos = (int)(nPixel * fRatio + nPosRangeMin + 0.5f);	}	else		nPos = (int)(nPixel * fRatio + nPosRangeMin + 0.5f);	return nPos;}// Opacity Height俊 措茄 谅钎函券int	  RxHistogram::PoToPiO(float fPos){	int		nTop	= HGSZ_SCROLL+HGSZ_SCROLL_MARGIN+HGSZ_OTF_TMARGIN;	int		nBottom	= m_szWindow.cy - (HGSZ_OTF_BMARGIN+HGSZ_SPECTRUM);	return	nBottom - (int)(fPos * (nBottom-nTop));}float RxHistogram::PiToPoO(int nPixel){	int		nBottom	= m_szWindow.cy - (HGSZ_OTF_BMARGIN+HGSZ_SPECTRUM);	float	fHeight = (float)(nBottom -	(HGSZ_SCROLL+HGSZ_SCROLL_MARGIN+HGSZ_OTF_TMARGIN));	return	((nBottom - nPixel) / fHeight);}/////////////////////////////////////////////////////////////////////////////BOOL RxHistogram::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) {	POINT		point;	GetCursorPos(&point);	ScreenToClient(&point);	int		_nHitTest = HitTest(point);	switch(_nHitTest)	{		case HGHT_SCROLL_LEFT :			// west-east cursor		case HGHT_SCROLL_RIGHT :		case HGHT_OTF_LINE1 :		case HGHT_OTF_LINE3 :			SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32644)));			return TRUE;		case HGHT_OTF_LINE2 :			// north-south cursor			SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32645)));			return TRUE;		case HGHT_SCROLL_CENTER :		// hand cursor		case HGHT_OTF_POINT1 :		case HGHT_OTF_POINT2 :		case HGHT_OTF_POINT3 :		case HGHT_OTF_POINT4 :			SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32649)));			return TRUE;	}		return CWnd::OnSetCursor(pWnd, nHitTest, message);}// MORE TO DO : this function need to operate the timer void RxHistogram::OnLButtonDown(UINT nFlags, CPoint point) {	int		nIndex		= -1;	int		nHitTest	= HitTest(point, &nIndex);	int		nDiff1,	nDiff2, nDiff3, nDiff4;	_OTF_POLYGON *pOTFPolygon;	if(nIndex > -1)		pOTFPolygon = (_OTF_POLYGON *)m_ArrayOTFPolygon.GetAt(nIndex);	switch(nHitTest)	{		// 胶农费官 沥焊		case HGHT_SCROLL_LEFT :			nDiff1 = m_stScroll.nPiMin - point.x;			break;		case HGHT_SCROLL_CENTER :			nDiff1 = m_stScroll.nPiMin - point.x;			nDiff2 = m_stScroll.nPiMax - point.x;			break;		case HGHT_SCROLL_RIGHT :			nDiff2 = m_stScroll.nPiMax - point.x;			break;		// OTF 沥焊		case HGHT_OTF_POINT1 :		case HGHT_OTF_POINT2 :		case HGHT_OTF_POINT3 :		case HGHT_OTF_POINT4 :		case HGHT_OTF_LINE1 :		case HGHT_OTF_LINE2 :		case HGHT_OTF_LINE3 :		case HGHT_OTF_POLYGON :		{			// 努腐等 OTF啊 Active啊 酒聪搁 Active肺 傈券			if(m_nActiveOTF != nIndex)			{				m_nActiveOTF = nIndex;				RedrawWnd();				SendMessageToOwner(OTF_ACTIVE_CHANGED);			}			// 急琶等 OTF啊 面盒洒 钎矫登瘤 臼疽促搁 Scroll scale甫 犁炼例茄促.(目辑狼 困摹档 窃膊 炼例)			// 胶农费狼 困摹甫 犁炼沥茄促.			int		nOldMin = m_stScroll.nPoMin;			int		nOldMax = m_stScroll.nPoMax;			int		nOldCur = PiToPoH(point.x, m_stScroll.nPoMin, m_stScroll.nPoMax);			if(m_stScroll.nPoMax - m_stScroll.nPoMin < pOTFPolygon->nPointPoX[3] - pOTFPolygon->nPointPoX[0])				m_stScroll.nPoMax = m_stScroll.nPoMin + pOTFPolygon->nPointPoX[3] - pOTFPolygon->nPointPoX[0];			if(m_stScroll.nPoMin > pOTFPolygon->nPointPoX[0])				m_stScroll.nPoMin = pOTFPolygon->nPointPoX[0];			if(m_stScroll.nPoMax < pOTFPolygon->nPointPoX[3])				m_stScroll.nPoMax = pOTFPolygon->nPointPoX[3];			if(nOldMin != m_stScroll.nPoMin || nOldMax != m_stScroll.nPoMax)			{				SetScroll(m_stScroll.nPoMin, m_stScroll.nPoMax);				// 目辑狼 困摹甫 官层霖促.				point.x = PoToPiH(nOldCur, m_stScroll.nPoMin, m_stScroll.nPoMax);				CPoint	ptTemp = point;				ClientToScreen(&ptTemp);				SetCursorPos(ptTemp.x, ptTemp.y);			}			if(nHitTest == HGHT_OTF_POINT1)				nDiff1 = pOTFPolygon->nPointPiX[0] - point.x;			else if(nHitTest == HGHT_OTF_POINT2)			{				nDiff1 = pOTFPolygon->nPointPiX[1] - point.x;				nDiff2 = pOTFPolygon->nPointPiY[1] - point.y;			}			else if(nHitTest == HGHT_OTF_POINT3)			{				nDiff1 = pOTFPolygon->nPointPiX[2] - point.x;				nDiff2 = pOTFPolygon->nPointPiY[2] - point.y;			}			else if(nHitTest == HGHT_OTF_POINT4)				nDiff1 = pOTFPolygon->nPointPiX[3] - point.x;			else if(nHitTest == HGHT_OTF_LINE1)			{				nDiff1 = pOTFPolygon->nPointPiX[0] - point.x;				nDiff2 = pOTFPolygon->nPointPiX[1] - pOTFPolygon->nPointPiX[0];			}			else if(nHitTest == HGHT_OTF_LINE2)				nDiff1 = pOTFPolygon->nPointPiY[1] - point.y;			else if(nHitTest == HGHT_OTF_LINE3)			{				nDiff1 = pOTFPolygon->nPointPiX[2] - point.x;				nDiff2 = pOTFPolygon->nPointPiX[3] - pOTFPolygon->nPointPiX[2];			}			else if(nHitTest == HGHT_OTF_POLYGON)			{				nDiff1 = pOTFPolygon->nPointPiX[0] - point.x;				nDiff2 = pOTFPolygon->nPointPiX[1] - pOTFPolygon->nPointPiX[0];				nDiff3 = pOTFPolygon->nPointPiX[2] - pOTFPolygon->nPointPiX[0];				nDiff4 = pOTFPolygon->nPointPiX[3] - pOTFPolygon->nPointPiX[0];			}			break;		}		default :			CWnd::OnLButtonDown(nFlags, point);			return;	}	SetCapture();	for (;;)	{		MSG		msg;		VERIFY(::GetMessage(&msg, NULL, 0, 0));		ScreenToClient(&msg.pt);		switch (msg.message)		{			case WM_MOUSEMOVE :				// 胶农费 官狼 困摹傈券				if(HGHT_SCROLL_LEFT <= nHitTest && nHitTest <= HGHT_SCROLL_RIGHT)				{					if(nHitTest == HGHT_SCROLL_LEFT)					{						int		nOldPiMin = m_stScroll.nPiMin;						m_stScroll.nPiMin = msg.pt.x+nDiff1;						if(m_stScroll.nPiMin <= 0)							m_stScroll.nPiMin = 0;						else if(m_stScroll.nPiMin + m_stScroll.nMinSize > m_stScroll.nPiMax)							m_stScroll.nPiMin = m_stScroll.nPiMax - m_stScroll.nMinSize;						if(nOldPiMin != m_stScroll.nPiMin)						{							m_stScroll.nPoMin = PiToPoH(m_stScroll.nPiMin,														m_stScroll.nRangeMinOut, m_stScroll.nRangeMaxOut);							RecalcOTFPolygon(FALSE);							RedrawWnd();						}					}					else if(nHitTest == HGHT_SCROLL_RIGHT)					{						int		nOldPiMax = m_stScroll.nPiMax;						m_stScroll.nPiMax = msg.pt.x+nDiff2;						if(m_stScroll.nPiMax >= m_szWindow.cx)							m_stScroll.nPiMax = m_szWindow.cx;						else if(m_stScroll.nPiMax - m_stScroll.nMinSize < m_stScroll.nPiMin)							m_stScroll.nPiMax = m_stScroll.nPiMin + m_stScroll.nMinSize;						if(nOldPiMax != m_stScroll.nPiMax)						{							m_stScroll.nPoMax = PiToPoH(m_stScroll.nPiMax,														m_stScroll.nRangeMinOut, m_stScroll.nRangeMaxOut);							RecalcOTFPolygon(FALSE);							RedrawWnd();						}					}					else if(nHitTest == HGHT_SCROLL_CENTER)					{						int		nOldPiMin = m_stScroll.nPiMin;						int		nOldPiMax = m_stScroll.nPiMax;						m_stScroll.nPiMin = msg.pt.x+nDiff1;						m_stScroll.nPiMax = msg.pt.x+nDiff2;						if(m_stScroll.nPiMin <= 0)						{							m_stScroll.nPiMax = m_stScroll.nPiMax - m_stScroll.nPiMin;							m_stScroll.nPiMin = 0;						}						else if(m_stScroll.nPiMax >= m_szWindow.cx)						{							m_stScroll.nPiMin = m_szWindow.cx - (m_stScroll.nPiMax - m_stScroll.nPiMin);							m_stScroll.nPiMax = m_szWindow.cx;						}						if(nOldPiMin != m_stScroll.nPiMin || nOldPiMax != m_stScroll.nPiMax)						{							m_stScroll.nPoMin = PiToPoH(m_stScroll.nPiMin,														m_stScroll.nRangeMinOut, m_stScroll.nRangeMaxOut);							m_stScroll.nPoMax = PiToPoH(m_stScroll.nPiMax,														m_stScroll.nRangeMinOut, m_stScroll.nRangeMaxOut);							RecalcOTFPolygon(FALSE);							RedrawWnd();						}					}				}				// OTF狼 困摹傈券				else if(HGHT_OTF_POINT1 <= nHitTest && nHitTest <= HGHT_OTF_POLYGON)				{					int		nTop	= HGSZ_SCROLL+HGSZ_SCROLL_MARGIN+HGSZ_OTF_TMARGIN;					int		nBottom	= m_szWindow.cy - (HGSZ_OTF_BMARGIN+HGSZ_SPECTRUM);					if(nHitTest == HGHT_OTF_POINT1)					{						int		nOldPiX = pOTFPolygon->nPointPiX[0];						// boundary check by pixel						pOTFPolygon->nPointPiX[0] = msg.pt.x+nDiff1;						if(pOTFPolygon->nPointPiX[0] <= 0)							pOTFPolygon->nPointPiX[0] = 0;						else if(pOTFPolygon->nPointPiX[0] >= pOTFPolygon->nPointPiX[1])							pOTFPolygon->nPointPiX[0] = pOTFPolygon->nPointPiX[1];						if(nOldPiX != pOTFPolygon->nPointPiX[0])						{							// pixel to position							pOTFPolygon->nPointPoX[0] = PiToPoH(pOTFPolygon->nPointPiX[0],																m_stScroll.nPoMin, m_stScroll.nPoMax);							// boundary check by position							if(pOTFPolygon->nPointPoX[0] > pOTFPolygon->nPointPoX[1])								pOTFPolygon->nPointPoX[0] = pOTFPolygon->nPointPoX[1];							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_POINT2)					{						int		nOldPiX = pOTFPolygon->nPointPiX[1];						int		nOldPiY = pOTFPolygon->nPointPiY[1];						// boundary check by pixel						pOTFPolygon->nPointPiX[1] = msg.pt.x+nDiff1;						pOTFPolygon->nPointPiY[1] = msg.pt.y+nDiff2;						if(pOTFPolygon->nPointPiX[1] <= pOTFPolygon->nPointPiX[0])							pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[0];						else if(pOTFPolygon->nPointPiX[1] >= pOTFPolygon->nPointPiX[2])							pOTFPolygon->nPointPiX[1] = pOTFPolygon->nPointPiX[2];						if(pOTFPolygon->nPointPiY[1] <= nTop)							pOTFPolygon->nPointPiY[1] = nTop;						else if(pOTFPolygon->nPointPiY[1] >= nBottom)							pOTFPolygon->nPointPiY[1] = nBottom;						if(nOldPiX != pOTFPolygon->nPointPiX[1] || nOldPiY != pOTFPolygon->nPointPiY[1])						{							// pixel to position							pOTFPolygon->nPointPiY[2] = pOTFPolygon->nPointPiY[1];							pOTFPolygon->nPointPoX[1] = PiToPoH(pOTFPolygon->nPointPiX[1],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->fOpacityPo   = PiToPoO(pOTFPolygon->nPointPiY[1]);							// boundary check by position							if(pOTFPolygon->nPointPoX[1] < pOTFPolygon->nPointPoX[0])								pOTFPolygon->nPointPoX[1] = pOTFPolygon->nPointPoX[0];							if(pOTFPolygon->nPointPoX[1] > pOTFPolygon->nPointPoX[2])								pOTFPolygon->nPointPoX[1] = pOTFPolygon->nPointPoX[2];							UpdateSpectrum();							RedrawWnd();							SendMessageToOwner(OTF_POS_CHANGED);						}					}					else if(nHitTest == HGHT_OTF_POINT3)					{						int		nOldPiX = pOTFPolygon->nPointPiX[2];						int		nOldPiY = pOTFPolygon->nPointPiY[2];						// boundary check by pixel						pOTFPolygon->nPointPiX[2] = msg.pt.x+nDiff1;						pOTFPolygon->nPointPiY[2] = msg.pt.y+nDiff2;						if(pOTFPolygon->nPointPiX[2] <= pOTFPolygon->nPointPiX[1])							pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[1];						else if(pOTFPolygon->nPointPiX[2] >= pOTFPolygon->nPointPiX[3])							pOTFPolygon->nPointPiX[2] = pOTFPolygon->nPointPiX[3];						if(pOTFPolygon->nPointPiY[2] <= nTop)							pOTFPolygon->nPointPiY[2] = nTop;						else if(pOTFPolygon->nPointPiY[2] >= nBottom)							pOTFPolygon->nPointPiY[2] = nBottom;						if(nOldPiX != pOTFPolygon->nPointPiX[2] || nOldPiY != pOTFPolygon->nPointPiY[2])						{							// pixel to position							pOTFPolygon->nPointPiY[1] = pOTFPolygon->nPointPiY[2];							pOTFPolygon->nPointPoX[2] = PiToPoH(pOTFPolygon->nPointPiX[2],																m_stScroll.nPoMin, m_stScroll.nPoMax);							pOTFPolygon->fOpacityPo   = PiToPoO(pOTFPolygon->nPointPiY[2]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -