728x90
1. 개요
VTK 스크린 화면에 정보를 출력할 때 쉽게 사용할 수 있는 vktCornerAnnotation 을 알아보려고 한다.
구현은 매우 쉬우므로 TextPosition의 정의와 정의되어 있는 Tag를 활용하는 방법을 설명한다.
2. TextPosition
Renderer 의 화면을 총 8개의 위치로 정의하며 각 위치별 index와 명칭은 아래와 같다.
public void TestTextPosition()
{
annotation.SetText((int) VtkTextPosition.LowerLeft,
$"{(int) VtkTextPosition.LowerLeft}-{VtkTextPosition.LowerLeft}");
annotation.SetText((int) VtkTextPosition.LowerRight,
$"{(int) VtkTextPosition.LowerRight}-{VtkTextPosition.LowerRight}");
annotation.SetText((int) VtkTextPosition.UpperLeft,
$"{(int) VtkTextPosition.UpperLeft}-{VtkTextPosition.UpperLeft}");
annotation.SetText((int) VtkTextPosition.UpperRight,
$"{(int) VtkTextPosition.UpperRight}-{VtkTextPosition.UpperRight}");
annotation.SetText((int) VtkTextPosition.LowerEdge,
$"{(int) VtkTextPosition.LowerEdge}-{VtkTextPosition.LowerEdge}");
annotation.SetText((int) VtkTextPosition.RightEdge,
$"{(int) VtkTextPosition.RightEdge}-{VtkTextPosition.RightEdge}");
annotation.SetText((int) VtkTextPosition.LeftEdge,
$"{(int) VtkTextPosition.LeftEdge}-{VtkTextPosition.LeftEdge}");
annotation.SetText((int) VtkTextPosition.UpperEdge,
$"{(int) VtkTextPosition.UpperEdge}-{VtkTextPosition.UpperEdge}");
annotation.GetProperty().SetColor(VtkColorUtils.GetNamedColor3d("Blue").ToIntPtr());
renderer.SetBackground(VtkColorUtils.GetNamedColor3d("Cornsilk").ToIntPtr());
renderWindow.SetSize(400, 400);
}
3. 이미지 Tag
Annotation 이 연결되어 있는 Renderer 의 입력 된 prop 중에 이미지 데이터가 있을 경우 해당 이미지 데이터에 대한 몇몇 정보를 Tag 만으로 쉽게 출력 할 수 있도록 한다.
<image> : will be replaced with slice number(relative number)
<slice> : will be replaced with slice number(relative number)
<image_and_max> : will be replaced with slice number and slice max(relative)
<slice_and_max> : will be replaced with slice number and slice max(relative)
<slice_pos> : will be replaced by the position of the current slice
<window> : will be replaced with window value
<level> : will be replaced with level value
<window_level> : will be replaced with window and level value
정의된 tag 에서 window 와 level의 경우에는 image actor의 입력 데이터에 vtkImageMapToWindowLevelColors filter가 정의되어 있어야 한다.
public void TestGetImageAnnotation()
{
EnableDrawAxes = false;
var filePath = Path.Combine(DirPath, "head.vti");
var reader = vtkXMLImageDataReader.New();
reader.SetFileName(filePath);
reader.Update();
annotation.SetText((int) VtkTextPosition.UpperRight, "<window>\n<level>");
annotation.SetText((int) VtkTextPosition.UpperLeft, "<image>\n<slice>");
annotation.SetText((int) VtkTextPosition.LowerRight, "<image_and_max>\n<slice_and_max>");
annotation.SetText((int) VtkTextPosition.LowerEdge, "<slice_pos>");
var imageData = reader.GetOutput();
var imageMap = vtkImageMapToWindowLevelColors.New();
imageMap.SetLevel(100);
imageMap.SetWindow(250);
imageMap.SetInputData(imageData);
var sliceMapper = vtkImageSliceMapper.New();
sliceMapper.SetInputConnection(imageMap.GetOutputPort());
sliceMapper.SetSliceNumber(0);
var imageActor = vtkImageActor.New();
imageActor.SetMapper(sliceMapper);
renderer.AddActor(imageActor);
vtkInteractorStyleImage imgStyle = vtkInteractorStyleImage.New();
interactor.SetInteractorStyle(imgStyle);
}
728x90
728x90