MIP 를 만들어보자.
2018, Jul 13
MIP 란 Max Intensity Projection 의 약자로 x, y 평면을 z 깊이 만큼 순회하면서 각 voxel의 최대값을 저장한 평면이다.
간단하게 평면을 z 만큼 반복하면서 최대값을 비교하여 만들 수 있다.
VolumeRendererDoc.cpp
void CVolumeRendererDoc::OnSlicerenderingMip()
{
// TODO: 여기에 명령 처리기 코드를 추가합니다.
int img_width = m_pVolume->getWidth();
int img_height = m_pVolume->getHeight();
int img_depth = m_pVolume->getDepth();
shared_ptr<unsigned char> Mip_Image =
shared_ptr<unsigned char>(new unsigned char[img_width*img_height]);
memset(Mip_Image.get(), 0, sizeof(unsigned char)*img_width*img_height);
// 평면을 깊이 z 만큼 순회하면서 최대값을 찾는다.
for (int z = 0; z < img_depth; z++)
{
for (int j = 0; j < img_height; j++)
{
for (int i = 0; i < img_width; i++)
{
// 현재 MIP 값과 voxel 값을 비교하여 큰 값을 MIP 에 저장한다.
Mip_Image.get()[img_width * j + i] =
__max(Mip_Image.get()[img_width * j + i],
m_pVolume->getVoxel(i, j, z));
}
}
}
CVolumeRendererView* pView =
(CVolumeRendererView*)((CMainFrame*)(AfxGetApp()->m_pMainWnd))->GetActiveView();
pView->SetDrawImage(Mip_Image.get(), img_width, img_height, 1);
pView->OnInitialUpdate();
}
기능을 실행하면 아래 그림과 같이 보인다.