<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1476" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>
<DIV><FONT size=2>Hi Luis,</FONT></DIV>
<DIV><FONT size=2> Hope you will help me again.</FONT></DIV>
<DIV><FONT size=2>I want to use LiverTumorSegmentation to do segmentation.But I
intend to extract a subregion and do segmentation on this
subregion.</FONT></DIV>
<DIV><FONT size=2>By two times respond to LeftButtonPressEvent I register
the region.For example, in different z-axial slices I click the left button and
register the positions.Then the two position record a cuboid region.The
functions as follows:</FONT></DIV>
<DIV><FONT size=2>// record a position in three dimensions</FONT></DIV>
<DIV><FONT size=2>void
LiverTumorSegmentation::RecordStartPoint()<BR>{<BR> m_StartPoint[0] =
int(saggitalViewSlider->value());<BR> m_StartPoint[1] =
int(coronalViewSlider->value());<BR> m_StartPoint[2] =
int(axialViewSlider->value());<BR> <BR>}</FONT></DIV>
<DIV><FONT size=2>//record another positon in three dimensions<BR>void
LiverTumorSegmentation::RecordEndPoint()<BR>{<BR> m_EndPoint[0] =
int(saggitalViewSlider->value());<BR> m_EndPoint[1] =
int(coronalViewSlider->value());<BR> m_EndPoint[2] =
int(axialViewSlider->value());<BR> <BR>}</FONT></DIV><FONT
size=2></FONT></FONT></DIV>
<DIV><FONT size=2><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT size=2>By calling the RecordStartPoint() and
RecordEndPoint() function,we can get two three-dimensions points to define the
interested region.</DIV>
<DIV><BR>//extract region</FONT></DIV>
<DIV><FONT size=2>void LiverTumorSegmentation::ExtractRegion()<BR>{
<BR> typedef itk::Image<unsigned char ,3>
OutputImageType;<BR> OutputImageType::Pointer m_ExtractedImage =
OutputImageType::New();<BR> if(m_LoadedVolume)<BR> {<BR> OutputImageType::IndexType
index;
<BR> index[0]=m_StartPoint[0];<BR> index[1]=m_StartPoint[1];<BR> index[2]=m_StartPoint[2];<BR> if(m_LoadedVolume->GetLargestPossibleRegion().IsInside(
index))<BR> { <BR> }<BR> else<BR> {<BR> fl_message("Index
is out of largest
region");<BR> }<BR> index[0]=m_EndPoint[0];<BR> index[1]=m_EndPoint[1];<BR> index[2]=m_EndPoint[2];<BR> if(m_LoadedVolume->GetLargestPossibleRegion().IsInside(
index))<BR> {<BR> }<BR> else<BR> {<BR> fl_message("Index
is out of largest
region");<BR> } <BR> <BR> OutputImageType::IndexType
tempIndex;
<BR> if(m_StartPoint[0]<m_EndPoint[0])<BR> {<BR> tempIndex[0]=m_StartPoint[0];<BR> }<BR> else<BR> {<BR> tempIndex[0]=m_EndPoint[0];<BR> }<BR> <BR> if(m_StartPoint[1]<m_EndPoint[1])<BR> {<BR> tempIndex[1]=m_StartPoint[1];<BR> }<BR> else<BR> {<BR> tempIndex[1]=m_EndPoint[1];<BR> }<BR> <BR> if(m_StartPoint[2]<m_EndPoint[2])<BR> {<BR> tempIndex[2]=m_StartPoint[2];<BR> }<BR> else<BR> {<BR> tempIndex[2]=m_EndPoint[2];<BR> }
<BR> <BR> <BR> OutputImageType::IndexType
start;<BR> start[0] = 0;<BR> start[1] =
0;<BR> start[2] =
0;<BR> <BR> OutputImageType::SizeType
size;<BR> size[0] = abs(m_EndPoint[0] -
m_StartPoint[0]+1);<BR> size[1] = abs(m_EndPoint[1] -
m_StartPoint[1]+1);<BR> size[2] = abs(m_EndPoint[2] -
m_StartPoint[2]+1);<BR> <BR> OutputImageType::RegionType
desiredRegion;<BR> desiredRegion.SetSize( size
);<BR> desiredRegion.SetIndex( start
);<BR> <BR> m_ExtractedImage->SetRegions(desiredRegion);<BR> m_ExtractedImage->Allocate();</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> OutputImageType::SpacingType
sp;<BR> sp=m_LoadedVolume->GetSpacing(); <BR> m_ExtractedImage->SetSpacing(sp);<BR> <BR> double
origin[3];<BR> origin[0] =
m_LoadedVolume->GetOrigin()[0];<BR> origin[1] =
m_LoadedVolume->GetOrigin()[1];<BR> origin[2] =
m_LoadedVolume->GetOrigin()[2];<BR> <BR> double
newOrigin[3];<BR> newOrigin[0] =
origin[0]+sp[0]*tempIndex[0];<BR> newOrigin[1] =
origin[1]+sp[1]*tempIndex[1];<BR> newOrigin[2] =
origin[2]+sp[2]*tempIndex[2];<BR> m_ExtractedImage->SetOrigin(newOrigin);<BR> OutputImageType::IndexType
pixelIndex;<BR> OutputImageType::IndexType
corPixelIndex;<BR> OutputImageType::PixelType
pixelValue;<BR> for(int
i=0;i<size[0];i++)<BR> {<BR> pixelIndex[0] =
i;<BR> corPixelIndex[0] =
i+tempIndex[0];<BR> for(int
j=0;j<size[1];j++)<BR> {<BR> pixelIndex[1]
= j;<BR> corPixelIndex[1] =
j+tempIndex[1];<BR> for(int
k=0;k<size[2];k++)<BR> {<BR> pixelIndex[2]=k;<BR> corPixelIndex[2]=k+tempIndex[2];<BR> pixelValue
=
m_LoadedVolume->GetPixel(corPixelIndex);<BR> m_ExtractedImage->SetPixel(pixelIndex,pixelValue);<BR> <BR> }<BR> }<BR> }<BR> <BR> } <BR> <BR> <BR> m_LoadedVolume
= m_ExtractedImage;<BR> <BR> m_ShiftScaleImageFilter->SetInput(
m_ITK2VTKAdaptor->GetOutput()
);<BR> <BR> this->SetSegmentedVolumeOpacityControlOff();<BR> <BR> this->LoadPostProcessing();<BR> <BR>}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>In the LiverTumorSegmentation I added the "int
m_StartPoint[3]" and "int m_EndPoint[3]".</DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT size=2>By these functions I get the interested region.But the display
is still slantwise.I write the m_ExtractedImage to a MetaImage
File.This file can be viewed by SNAP.</FONT></DIV>
<DIV><FONT size=2>Is there something wrong?Why the visualization is slant? I
really need your help.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Thanks</FONT></DIV>
<DIV><FONT size=2>Diaoxianfen</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV></FONT></BODY></HTML>