[Insight-users] Computing Hessian Matrix of Large Image

Jianxu Chen jchen16 at nd.edu
Sat Nov 10 15:03:52 EST 2012


Hello Kevin,

Could you give me a little more details about how to use
StreamingImageFilter()? I tried it  with the following code. But the error
"Failed to Allocate Memory For Image" still happened. I don't have much
experience in ITK. Maybe the streaming filter is employed in an incorrect
way.

The pipeline is ImageReader() --> StreamingFilter() --> HessianFilter() -->
HessianToObjectnessFilter() --> ImageWriter()

Here is part of the code:

typedef itk::StreamingImageFilter<InputImageType, InputImageType>
StreamingFilterType;
StreamingFilterType::Pointer streaming = StreamingFilterType::New();
streaming->SetInput(imageReader->GetOutput());
streaming->SetNumberOfStreamDivisions(8);

typedef itk::HessianRecursiveGaussianImageFilter< InputImageType >
HessianMatrixFilterType;
HessianMatrixFilterType::Pointer hessianMatrix =
HessianMatrixFilterType::New();
hessianMatrix->SetInput(streaming->GetOutput());

typedef itk::HessianToObjectnessMeasureImageFilter<
HessianMatrixFilterType::OutputImageType,OutputImageType >
ObjectnessFilterType;
ObjectnessFilterType::Pointer objectnessFilter =
ObjectnessFilterType::New();
objectnessFilter->SetInput(hessianMatrix->GetOutput());
** Next, Set the parameter for ObjectnessFilter **
** Finally, Submit to Image Writer **

Thanks a lot for your help.
Jianxu Chen


On Tue, Nov 6, 2012 at 9:39 AM, Jianxu Chen <jchen16 at nd.edu> wrote:

> Hello Kevin,
>
> Really appreciate your suggestion. I found that  "SetNumberOfStreamDivisions"
> is really powerful when handling large data.
>
> For the Hessian Matrix Filter, I noticed that this problem had already
> been discussed via the maillist in 2008.
>
>
> http://www.itk.org/pipermail/insight-users/2008-June/026328.html
>
> Some tests were conducted there. It showed that it might fail to allocate
> memory for the Hessian matrix even when there should be enough space
> theoretically.
>
> Anyway, your suggestion of using SetNumberOfStreamDivisions is very
> useful. My problem can be solved.
>
> Thanks again for your help.
> Jianxu Chen
>
> On Tue, Nov 6, 2012 at 9:26 AM, Kevin H. Hobbs <hobbsk at ohio.edu> wrote:
>
>> On 11/04/2012 03:50 PM, Jianxu Chen wrote:
>> > Hello,
>> >
>> > I encountered a weird problem when computing the Hessian Matrix of a 3D
>> > image stack.
>> >
>> > I used HessianRecursiveGaussianImageFilter to compte the Hessian matrix.
>> > However, this filter only works well when the image is very very small.
>> >
>> > My data is a 1024*1024*30 image stack. When calling
>> > HessianRecursiveGaussianImageFilter to calculate the Hessian matrix, the
>> > system cannot allocate the memory space for it. Thus, I cut my data into
>> > a 350*350*30 image stack. The program works well. My computer has a 8GB
>> > RAM and is a 64-bit machine. I am wondering why the system fails to
>> > allocate the memory for the filter. There should be enough usable RAM in
>> > the machine.
>>
>> If your data are unsigned char : 1024*1024*100 / 2^20 = 100 MiB.
>> If your data are floats : 1024*1024*100 * 4 / 2^20 = 400 MiB.
>> If your data are doubles : 1024*1024*100 * 8 / 2^20 = 800 MiB.
>>
>> The Hessian matrix is symmetric so only 6 values are required :
>>         1024*1024*100 * 8 * 6 / 2^30 = 4.69 GiB.
>>
>> If you have a long pipeline your image could be in memory in many places.
>>
>> >
>> > My data is at least 1024*1024*30, sometimes even 1024*1024*100. And I
>> > have to compute the Hessian matrix in my algorithm. What should I do in
>> > this case? Could you give my some advice? Really appreciate your help.
>> >
>>
>> Shorten your pipeline. Reader => Filter => Writer.
>>
>> Set the ReleaseDataFlag or GlobalReleaseDataFlag so that filters free
>> their data after satisfying downstream requests.
>>
>> Stream your pipeline :
>>         writer->SetNumberOfStreamDivisions( n );
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121110/f62022e9/attachment.htm>


More information about the Insight-users mailing list