<!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>&nbsp;&nbsp; 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&nbsp;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>&nbsp;m_StartPoint[0] = 
int(saggitalViewSlider-&gt;value());<BR>&nbsp;m_StartPoint[1] = 
int(coronalViewSlider-&gt;value());<BR>&nbsp;m_StartPoint[2] = 
int(axialViewSlider-&gt;value());<BR>&nbsp;<BR>}</FONT></DIV>
<DIV><FONT size=2>//record another positon in three dimensions<BR>void 
LiverTumorSegmentation::RecordEndPoint()<BR>{<BR>&nbsp;m_EndPoint[0] = 
int(saggitalViewSlider-&gt;value());<BR>&nbsp;m_EndPoint[1] = 
int(coronalViewSlider-&gt;value());<BR>&nbsp;m_EndPoint[2] = 
int(axialViewSlider-&gt;value());<BR>&nbsp;<BR>}</FONT></DIV><FONT 
size=2></FONT></FONT></DIV>
<DIV><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</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>{&nbsp; 
&nbsp;<BR>&nbsp;typedef itk::Image&lt;unsigned char ,3&gt;&nbsp; 
OutputImageType;<BR>&nbsp;OutputImageType::Pointer m_ExtractedImage = 
OutputImageType::New();<BR>&nbsp;if(m_LoadedVolume)<BR>&nbsp;{<BR>&nbsp;&nbsp;OutputImageType::IndexType 
index; 
<BR>&nbsp;&nbsp;index[0]=m_StartPoint[0];<BR>&nbsp;&nbsp;index[1]=m_StartPoint[1];<BR>&nbsp;&nbsp;index[2]=m_StartPoint[2];<BR>&nbsp;&nbsp;if(m_LoadedVolume-&gt;GetLargestPossibleRegion().IsInside( 
index))<BR>&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;fl_message("Index 
is out of largest 
region");<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;index[0]=m_EndPoint[0];<BR>&nbsp;&nbsp;index[1]=m_EndPoint[1];<BR>&nbsp;&nbsp;index[2]=m_EndPoint[2];<BR>&nbsp;&nbsp;if(m_LoadedVolume-&gt;GetLargestPossibleRegion().IsInside( 
index))<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;fl_message("Index 
is out of largest 
region");<BR>&nbsp;&nbsp;}&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;OutputImageType::IndexType 
tempIndex; 
<BR>&nbsp;&nbsp;if(m_StartPoint[0]&lt;m_EndPoint[0])<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;tempIndex[0]=m_StartPoint[0];<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;tempIndex[0]=m_EndPoint[0];<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;if(m_StartPoint[1]&lt;m_EndPoint[1])<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;tempIndex[1]=m_StartPoint[1];<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;tempIndex[1]=m_EndPoint[1];<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;if(m_StartPoint[2]&lt;m_EndPoint[2])<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;tempIndex[2]=m_StartPoint[2];<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;tempIndex[2]=m_EndPoint[2];<BR>&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;OutputImageType::IndexType 
start;<BR>&nbsp;&nbsp;start[0] = 0;<BR>&nbsp;&nbsp;start[1] = 
0;<BR>&nbsp;&nbsp;start[2] = 
0;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;OutputImageType::SizeType 
size;<BR>&nbsp;&nbsp;size[0] = abs(m_EndPoint[0] - 
m_StartPoint[0]+1);<BR>&nbsp;&nbsp;size[1] = abs(m_EndPoint[1] - 
m_StartPoint[1]+1);<BR>&nbsp;&nbsp;size[2] = abs(m_EndPoint[2] - 
m_StartPoint[2]+1);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;OutputImageType::RegionType 
desiredRegion;<BR>&nbsp;&nbsp;desiredRegion.SetSize( size 
);<BR>&nbsp;&nbsp;desiredRegion.SetIndex( start 
);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;m_ExtractedImage-&gt;SetRegions(desiredRegion);<BR>&nbsp;&nbsp;m_ExtractedImage-&gt;Allocate();</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;&nbsp;OutputImageType::SpacingType 
sp;<BR>&nbsp;&nbsp;sp=m_LoadedVolume-&gt;GetSpacing();&nbsp;&nbsp;<BR>&nbsp;&nbsp;m_ExtractedImage-&gt;SetSpacing(sp);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;double 
origin[3];<BR>&nbsp;&nbsp;origin[0] = 
m_LoadedVolume-&gt;GetOrigin()[0];<BR>&nbsp;&nbsp;origin[1] = 
m_LoadedVolume-&gt;GetOrigin()[1];<BR>&nbsp;&nbsp;origin[2] = 
m_LoadedVolume-&gt;GetOrigin()[2];<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;double 
newOrigin[3];<BR>&nbsp;&nbsp;newOrigin[0] = 
origin[0]+sp[0]*tempIndex[0];<BR>&nbsp;&nbsp;newOrigin[1] = 
origin[1]+sp[1]*tempIndex[1];<BR>&nbsp;&nbsp;newOrigin[2] = 
origin[2]+sp[2]*tempIndex[2];<BR>&nbsp;&nbsp;m_ExtractedImage-&gt;SetOrigin(newOrigin);<BR>&nbsp;&nbsp;OutputImageType::IndexType 
pixelIndex;<BR>&nbsp;&nbsp;OutputImageType::IndexType 
corPixelIndex;<BR>&nbsp;&nbsp;OutputImageType::PixelType 
pixelValue;<BR>&nbsp;&nbsp;for(int 
i=0;i&lt;size[0];i++)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;pixelIndex[0] = 
i;<BR>&nbsp;&nbsp;&nbsp;corPixelIndex[0] = 
i+tempIndex[0];<BR>&nbsp;&nbsp;&nbsp;for(int 
j=0;j&lt;size[1];j++)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;pixelIndex[1] 
= j;<BR>&nbsp;&nbsp;&nbsp;&nbsp;corPixelIndex[1] = 
j+tempIndex[1];<BR>&nbsp;&nbsp;&nbsp;&nbsp;for(int 
k=0;k&lt;size[2];k++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pixelIndex[2]=k;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;corPixelIndex[2]=k+tempIndex[2];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pixelValue 

m_LoadedVolume-&gt;GetPixel(corPixelIndex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_ExtractedImage-&gt;SetPixel(pixelIndex,pixelValue);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;}&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;m_LoadedVolume 
= m_ExtractedImage;<BR>&nbsp;<BR>&nbsp;m_ShiftScaleImageFilter-&gt;SetInput( 
m_ITK2VTKAdaptor-&gt;GetOutput() 
);<BR>&nbsp;<BR>&nbsp;this-&gt;SetSegmentedVolumeOpacityControlOff();<BR>&nbsp;<BR>&nbsp;this-&gt;LoadPostProcessing();<BR>&nbsp;<BR>}</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>In the LiverTumorSegmentation I added the&nbsp;"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&nbsp;slantwise.I write the m_ExtractedImage to a&nbsp;MetaImage 
File.This file&nbsp;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>&nbsp;</DIV>
<DIV><FONT size=2>Thanks</FONT></DIV>
<DIV><FONT size=2>Diaoxianfen</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV></FONT></BODY></HTML>