Hi Maximilien,<br><br>A) For pasting the values back in to the image, <br> you may want to use the MaskImageFilter or<br> the NegatedMaskImageFilter.<br><br><br>B) Most ITK filters are N-Dimensional. <br> The region growing filters will work fine in <br>
2D, 3D, 4D....<br><br>C) You may start by debugging your process of<br> copying images in and out of ITK. It doesn't<br> seem that your problem is related to the<br> region growing itself.<br><br><br>
Regards,<br><br><br> Luis<br><br><br>------------------------------------------------<br><div class="gmail_quote">On Sat, Jul 25, 2009 at 6:17 AM, Maximilien Renard <span dir="ltr"><<a href="mailto:iixamaxii@gmail.com">iixamaxii@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi there,<br>
<br>
I'm trying to realize a function (Fill3D) that uses the connected<br>
threshold filter to fill a region of a 3D image with another value<br>
based on a threshold.<br>
<br>
This is the function I'm using now :<br>
<br>
void CVolumeData::Fill3D(int X, int Y, int Z, unsigned short<br>
LowThreshold, unsigned short HighThreshold, unsigned short<br>
ReplacementValue) {<br>
typedef itk::ConnectedThresholdImageFilter < ITK3DImageType,<br>
ITK3DImageType> FilterType;<br>
FilterType::Pointer filter = FilterType::New();<br>
ITK3DImageType::IndexType seed;<br>
seed[0] = X;<br>
seed[1] = Y;<br>
seed[2] = Z;<br>
CVolumeData *pResultImage;<br>
int DimX, DimY, DimZ, x, y, z;<br>
<br>
filter->SetSeed(seed);<br>
filter->SetLower(LowThreshold);<br>
filter->SetUpper(HighThreshold);<br>
filter->SetReplaceValue(4000);<br>
<br>
filter->SetInput(GetITK3DImage());<br>
filter->Update();<br>
pResultImage = new CVolumeData(m_MainView);<br>
pResultImage->SetITK3DImage(filter->GetOutput());<br>
<br>
GetDimensions(DimX, DimY, DimZ);<br>
<br>
for (z = 0; z < DimZ; z++)<br>
for (y = 0; y < DimY; y++)<br>
for (x = 0; x < DimX; x++) {<br>
if (pResultImage->GetVoxel(x, y, z) >= 4000) {<br>
SetVoxel(x, y, z, ReplacementValue);<br>
}<br>
}<br>
<br>
delete(pResultImage);<br>
}<br>
<br>
The last 3 for (DimZ, DimY and DimX) are necessary to replace the<br>
filled zone in the original image without replacing the zone of the<br>
original image which lies outside the threshold values. Sadly it takes<br>
lots of time. Is there a better way to do this ?<br>
<br>
Next question, I need to do a Fill2D function too. Here again I have a<br>
problem. I use the extract image filter to extract the slice I need,<br>
then I apply the Fill3D filter on the image (Fill3D that doesn't work<br>
properly now) and what I wanted to do is use the PasteImageFilter to<br>
paste the result of the Fill3D (which has only one slice) back into<br>
the original 3D Image.<br>
<br>
But once again it doesn't work. The result is that the new slice is<br>
entirely black...<br>
<br>
void CVolumeData::Fill2D(int X, int Y, int Z, unsigned short<br>
LowThreshold, unsigned short HighThreshold, unsigned short<br>
ReplacementValue, int SubView) {<br>
int DimX, DimY, DimZ;<br>
int x, y, z;<br>
<br>
GetDimensions(DimX, DimY, DimZ);<br>
<br>
typedef itk::ExtractImageFilter< ITK3DImageType, ITK3DImageType > FilterType;<br>
FilterType::Pointer filter = FilterType::New();<br>
<br>
ITK3DImageType::RegionType inputRegion =<br>
GetITK3DImage()->GetLargestPossibleRegion();<br>
<br>
if (SubView == CMainView::MODE_XY) {<br>
CVolumeData SliceVolume(m_MainView);<br>
<br>
SliceVolume.CreateVolume(DimX, DimY, 1, 1.0f, 1.0f, 1.0f, 0, false);<br>
<br>
ITK3DImageType::SizeType size = inputRegion.GetSize();<br>
size[2] = 1;<br>
ITK3DImageType::IndexType start = inputRegion.GetIndex();<br>
start[2] = Z;<br>
ITK3DImageType::RegionType desiredRegion;<br>
desiredRegion.SetSize(size);<br>
desiredRegion.SetIndex(start);<br>
<br>
filter->SetExtractionRegion(desiredRegion);<br>
<br>
filter->SetInput(GetITK3DImage());<br>
<br>
filter->Update();<br>
<br>
SliceVolume.SetITK3DImage(filter->GetOutput());<br>
<br>
SliceVolume.Fill3D(X, Y, 0, LowThreshold, HighThreshold, ReplacementValue);<br>
<br>
typedef itk::PasteImageFilter< ITK3DImageType, ITK3DImageType,<br>
ITK3DImageType > ImageReplacementFilterType;<br>
ImageReplacementFilterType::Pointer ImageReplacementFilter =<br>
ImageReplacementFilterType::New();<br>
<br>
ImageReplacementFilter->SetSourceImage(SliceVolume.GetITK3DImage());<br>
ImageReplacementFilter->SetSourceRegion(SliceVolume.GetITK3DImage()->GetLargestPossibleRegion());<br>
<br>
ImageReplacementFilter->SetDestinationImage(GetITK3DImage());<br>
ImageReplacementFilter->SetDestinationIndex(start);<br>
<br>
ImageReplacementFilter->Update();<br>
SetITK3DImage(ImageReplacementFilter->GetOutput());<br>
}<br>
}<br>
<br>
I'd enjoy any kind of help !<br>
<br>
Thank you very much,<br>
<br>
Best regards,<br>
<br>
<br>
Maximilien Renard<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>