[Insight-users] ConnectedThresholdImageFilter on one slice only ?

Maximilien Renard iixamaxii at gmail.com
Mon Jan 5 09:14:42 EST 2009


Hi again,

I'm sorry but it becomes quite urging now. Is my question still not
understandable ?

I'd like someone to give me an example of the use of the PasteImageFilter.
I've already tried several things (which under what it is written
below) but nothing has worked yet. What I'm I doing wrong ?

Thanks a lot,

Best regards,

Maximilien

2009/1/1 Maximilien Renard <iixamaxii at gmail.com>:
> Hi Luis,
>
> 1) Yes
>
> 2) Yes
>
> What I'm not able to do is using the PasteImageFilter which (if I'm
> right) should copy the output of the ConnectedThresholdFilter on the
> original image in the the 3D image.
>
> I've tried to do that with the code pasted below but it didn't work.
> CVolumeData SliceVolume contains the ITK 3D Image and the class where
> this code is written is CVolumeData.
>
>                typedef itk::PasteImageFilter< ITK3DImageType, ITK3DImageType,
> ITK3DImageType > ImageReplacementFilterType;
>                ImageReplacementFilterType::Pointer ImageReplacementFilter =
> ImageReplacementFilterType::New();
>
>                ImageReplacementFilter->SetInput(SliceVolume.GetITK3DImage());
>                ImageReplacementFilter->SetSourceImage(SliceVolume.GetITK3DImage());
>                ImageReplacementFilter->SetDestinationImage(GetITK3DImage());
>
>                ImageReplacementFilter->SetDestinationIndex(start);
>                ImageReplacementFilter->Update();
>
> When trying to execute the program, I've got this error :
>
>                Qt has caught an exception thrown from an event handler. Throwing
>                exceptions from an event handler is not supported in Qt. You must
>                reimplement QApplication::notify() and catch all exceptions there.
>
>                terminate called after throwing an instance of
> 'itk::InvalidRequestedRegionError'
>                what():  /home/ixm/InsightToolkit-3.8.0/Code/Common/itkDataObject.cxx:397:
>                Requested region is (at least partially) outside the largest possible region.
>                The program has unexpectedly finished.
>
> What am I doing wrong ?
>
> Thanks a lot and I wish you an happy new year.
>
> Maximilien
>
> 2008/12/31 Luis Ibanez <luis.ibanez at kitware.com>:
>>
>> Hi Maximilien,
>>
>> Let's cut the problem in pieces...
>>
>>   1) Have you managed to extract one 2D slice
>>      from the input 3D image, using the ExtractImageFilter ?
>>
>>   2) Did you manage to run the ConnectedThreshold filter
>>      in the 2D slice ?
>>
>> Please let us know,
>>
>>
>>    Thanks
>>
>>
>>       Luis
>>
>>
>> -------------------------
>> Maximilien Renard wrote:
>>>
>>> Hi there again,
>>>
>>> Can't anybody please tell me how I can get this to work or what I'm
>>> doing wrong, I've tried several times to read the doc and I
>>> unfortunately still don't understand what I should do.
>>>
>>> I would really appreciate any little help.
>>>
>>> Thanks a lot,
>>>
>>> Maximilien
>>>
>>> P.S. Right before I wanted to send this e-mail, I've just noticed I
>>> would have sent this e-mail (like the other one just here below) to
>>> Luis Ibanez only. This was a mistake :)
>>>
>>> 2008/12/26 Maximilien Renard <iixamaxii at gmail.com>:
>>>
>>>> Hi Luis,
>>>>
>>>> Thank you for your answer, I was actually using a self-made method
>>>> that was using GetBufferPointer(). This method was called for each
>>>> voxel of the image which is probably why it was slow.
>>>>
>>>> Now, I'm trying to use the ImagePasteFilter but I must say, I couldn't
>>>> understand how it should be used. I've made following :
>>>>
>>>> SliceVolume.Fill3D(X, Y, 0, LowThreshold, HighThreshold,
>>>> ReplacementValue); // Which then contains the image with the selected
>>>> region filled
>>>>
>>>> typedef itk::PasteImageFilter< ITK3DImageType, ITK3DImageType,
>>>> ITK3DImageType > ImageReplacementFilterType;
>>>> ImageReplacementFilterType::Pointer ImageReplacementFilter =
>>>> ImageReplacementFilterType::New();
>>>>
>>>> ImageReplacementFilter->SetInput(SliceVolume.GetITK3DImage());
>>>> ImageReplacementFilter->SetSourceImage(SliceVolume.GetITK3DImage());
>>>> ImageReplacementFilter->SetDestinationImage(GetITK3DImage());
>>>>
>>>> ImageReplacementFilter->SetDestinationIndex(start);
>>>> ImageReplacementFilter->Update();
>>>>
>>>> If I try to use this, I'm getting this message :
>>>>
>>>> Qt has caught an exception thrown from an event handler. Throwing
>>>> exceptions from an event handler is not supported in Qt. You must
>>>> reimplement QApplication::notify() and catch all exceptions there.
>>>>
>>>> terminate called after throwing an instance of
>>>> 'itk::InvalidRequestedRegionError'
>>>> what():
>>>>  /home/ixm/InsightToolkit-3.8.0/Code/Common/itkDataObject.cxx:397:
>>>> Requested region is (at least partially) outside the largest possible
>>>> region.
>>>> The program has unexpectedly finished.
>>>>
>>>> I've searched a little bit on the internet if I can found some example
>>>> of the use of this filter but I didn't find anything (maybe I'm
>>>> missing something that would make the doc cristal clear for me ?)
>>>>
>>>> Anyway I really appreciate your help,
>>>>
>>>> Thank you very much,
>>>>
>>>> Maximilien
>>>>
>>>> 2008/12/25 Luis Ibanez <luis.ibanez at kitware.com>:
>>>>
>>>>> Hi Maximilien,
>>>>>
>>>>> The process you are describing seems to be a reasonable
>>>>> way of doing this.
>>>>>
>>>>>
>>>>> More specifically:
>>>>>
>>>>>  1) Extract the slice with the
>>>>>
>>>>>                  "ExtractImageFilter"
>>>>>
>>>>>  2) Run the connectedThresholdImageFilter
>>>>>    in 2D on the extracted slice
>>>>>
>>>>>
>>>>>  3) Copy the slice back to the image, using the
>>>>>
>>>>>            "PasteImageFilter"
>>>>>
>>>>>
>>>>> I'm surprised to hear that the last part takes a lot of
>>>>> time. It should take a couple of seconds at most.
>>>>> Were you doing this by using ImageIterators ?
>>>>> or were you using calls to SetPixel() and GetPixel() ?
>>>>>
>>>>> Please give it a try to the PasteImageFilter
>>>>>
>>>>> http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html
>>>>>
>>>>> and let us know if you still experience any problems.
>>>>>
>>>>>
>>>>>  Regards,
>>>>>
>>>>>
>>>>>      Luis
>>>>>
>>>>>
>>>>>
>>>>> -------------------------
>>>>> Maximilien Renard wrote:
>>>>>
>>>>>> Hi there,
>>>>>>
>>>>>> I'm trying to use ConnectedThresholdImageFilter on one slice of an 3D
>>>>>> Image only (the result should be the original image exactly the same
>>>>>> except the specified slice where we put the seed).
>>>>>> Now I'm extracting the slice into a new 3D Image where it is alone,
>>>>>> then I apply the filter and finally I copy every voxel of the filtered
>>>>>> image one by one into the original one. But that takes a lot of time
>>>>>> (the last step is very long).
>>>>>>
>>>>>> Is there a better way to do that ? I'm new to ITK and I'm not
>>>>>> acknowledged with ITK Doxygen documentation which is quite hermetic
>>>>>> for me (I was used to read documentations such as the one of PHP or
>>>>>> Qt).
>>>>>>
>>>>>> Thanks for your future help,
>>>>>>
>>>>>> Best regards and merry christmas,
>>>>>>
>>>>>> Maximilien Renard
>>>>>> _______________________________________________
>>>>>> Insight-users mailing list
>>>>>> Insight-users at itk.org
>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>
>>>>>
>>>
>>
>


More information about the Insight-users mailing list