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

📄 raycastingfusionagent.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
字号:
// RayCastingFusionAgent.cpp : implementation file////////////////////////////////////////////////////////////////////////////	Title: Fusion Agent////////////////////////////////////////////////////////////////////////////	Author: H.W.Kye//	138-dong 417-ho Seoul National University//	San 56-1 Shinlim-dong Kwanak-gu Seoul, Korea//	Email. ////	Date	://	Update	:////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	include//////////////////////////////////////////////////////////////////////#include "StdAfx.h"#include "VRRayCastingAgent.h"#include "RayCastingFusionAgent.h"#include "RayCastingCommonInfo.h"////////////////////////////////////////////////////////////////////////	declaration//////////////////////////////////////////////////////////////////////// image level俊辑绰 SetAgnets -> InitRenderingBOOL AlphaComposite(BYTE *pBackgroundImage, BYTE *pForegroundImage, BYTE *pOutputImage,					CSize szImage, float fBackWeight);//////////////////////////////////////////////////////////////////////// RxRayCastingFusionAgentRxRayCastingFusionAgent::RxRayCastingFusionAgent() : RxRayCastingCommonAgent(0){	m_pImage = NULL;	m_szImage = CSize(0,0);	m_pRefImage = NULL;	m_pFltImage = NULL;	m_iFusionMode = FUSION_IMAGELEVEL;	m_fIntermixingWeight = 0.5f;	m_pFloatAgent = NULL;	m_pReferenceAgent = NULL;}RxRayCastingFusionAgent::~RxRayCastingFusionAgent(){	if(m_pImage) {		delete []m_pImage;		m_pImage = NULL;	}}BOOL RxRayCastingFusionAgent::SetAgents(RxVRRayCastingAgent *pRef, RxVRRayCastingAgent *pFlt){	m_pReferenceAgent = pRef;	m_pFloatAgent = pFlt;	return TRUE;}BOOL RxRayCastingFusionAgent::InitRendering(RxRayCastingCommonInfo *pReferenceInfo, RxRayCastingCommonInfo *pFloatInfo){	ASSERT(m_iFusionMode == FUSION_SAMPLELEVEL || (m_pFloatAgent && m_pReferenceAgent));	if(!(m_pFloatAgent && m_pReferenceAgent)) {		return FALSE;	}	ASSERT(pReferenceInfo != pFloatInfo);	if(m_szImage != pReferenceInfo->m_szImage) {		if(m_pImage) {			delete m_pImage;			m_pImage = NULL;		}		m_pImage = new unsigned char [pReferenceInfo->m_szImage.cx*pReferenceInfo->m_szImage.cy*4];	}	BOOL bRetvalFloat = m_pFloatAgent->InitRendering(pFloatInfo);	BOOL bRetvalReference = m_pReferenceAgent->InitRendering(pReferenceInfo);	return (bRetvalFloat && bRetvalReference);}LPBYTE RxRayCastingFusionAgent::Render(RxRayCastingCommonInfo *pReferenceInfo, RxRayCastingCommonInfo *pFloatInfo){	ASSERT(m_iFusionMode == FUSION_SAMPLELEVEL || (m_pFloatAgent && m_pReferenceAgent));	if(!(m_pFloatAgent && m_pReferenceAgent)) {		return NULL;	}	if(m_iFusionMode == FUSION_IMAGELEVEL)		return RenderImageLevel(pReferenceInfo, pFloatInfo);	else		return RenderSampleLevel(pReferenceInfo, pFloatInfo);}LPBYTE RxRayCastingFusionAgent::ChangeWeight(float fWeight){	ASSERT(fWeight >= 0 && fWeight <= 1);	m_fIntermixingWeight = fWeight;	AlphaComposite(m_pRefImage, m_pFltImage, m_pImage, m_szImage, m_fIntermixingWeight);	return m_pImage;}LPBYTE RxRayCastingFusionAgent::RenderImageLevel(RxRayCastingCommonInfo *pReferenceInfo, RxRayCastingCommonInfo *pFloatInfo){	m_pRefImage = m_pReferenceAgent->Render(pReferenceInfo);	if(m_pRefImage) {		m_pFltImage = m_pFloatAgent->Render(pFloatInfo);		if(m_pFltImage) {			m_szImage = pReferenceInfo->m_szImage;			AlphaComposite(m_pRefImage, m_pFltImage, m_pImage, pReferenceInfo->m_szImage, m_fIntermixingWeight);			return m_pImage;		}	}	m_pRefImage = m_pFltImage = NULL;	TRACE(_T("Fusion mode interrupted"));	return NULL;}LPBYTE RxRayCastingFusionAgent::RenderSampleLevel(RxRayCastingCommonInfo *pReferenceInfo, RxRayCastingCommonInfo *pFloatInfo){	return RenderNormal();}LPBYTE RxRayCastingFusionAgent::RenderNormal(){	int iPart = 1; // single CPU	int iMinX=0, iMinY=0, iMaxX=m_iImgX-1, iMaxY=m_iImgY-1;	GetRayImageBound(&iMinX, &iMinY, &iMaxX, &iMaxY);	int iSkip = 1<<m_iLevel;	int iStartY = __max(iMinY, m_iImgY/(int)m_dwNumberOfCPU*(iPart-1)) + (iSkip-1);	int iEndY = __min(iMaxY, m_iImgY/(int)m_dwNumberOfCPU*(iPart)) + (iSkip-1);/*	for (int iy = iStartY; iy < iEndY; iy += iSkip) {		for (ix = iMinX; ix < iMaxX; ix += iSkip) {			float r=0, g=0, b=0, opacity=0;			int iPrevSampleDensity = INIT_VALUE;			float d1[4] = {IntToFloat(ix), IntToFloat(iy), 10 , 1};			m4v4mulf(afRayOrigin, m_afInvViewingM, d1);			int iType=0;			int idx = 4*((ix/iSkip)+(iy/iSkip)*(m_iImgX/iSkip));			float min_t, max_t;			float afRayOrigin[4];			iType = GetRaySampleBound(iPart, afRayOrigin, &min_t, &max_t, &r, &g, &b, &opacity);			// 版拌 贸府 绝澜		}	}*/	return NULL;}/* rapidia 2.1狼 common agent俊辑 啊廉棵巴int RxRayCastingFusionAgent::GetRaySampleBound(int iPart, float *afRayOrigin, float *min_t, float *max_t, float* r, float* g, float* b, float* opacity){	float tmin,  tmax, tmp;	int i;	*min_t = -MAX_T;	*max_t = MAX_T;	int iFirst = 7, iPos;	for (i=0;i<3;i++) {		iPos = i+1;		if (__abs(m_afRayDirection[i])>0.00001f) {			tmax = (m_afCropMax[i]-0.1f-afRayOrigin[i])*m_afInvRayDirection[i];			tmin = (m_afCropMin[i]+0.1f-afRayOrigin[i])*m_afInvRayDirection[i];			if (tmax < tmin) {				tmp = tmax;				tmax = tmin;				tmin = tmp;				iPos+=3;			}			if (tmin > *min_t) {				*min_t = tmin;				iFirst = iPos;			}			if (tmax < *max_t)				*max_t = tmax;		}	}	if (*min_t > *max_t)		return 0;	return iFirst;}*/

⌨️ 快捷键说明

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