[Insight-users] LabelImageToStatisticsLabelMapFilter speed
Soren Christensen
sorench at gmail.com
Mon Feb 11 00:42:49 EST 2013
Hi,
I am looking for some pointers of what I can do to speed up the following:
I am extracting the mean of a 3D ROI in each of the frames of a 4D image
(so in each )
Background: objlabelstatsfilter has float3dimage as feature image and a
uchar (label) as inputs. In the below code I iterate over the frames (by
changing the pointer of a 3D feature image) and then extract the label
stats. Each filter update takes about 22 ms which is on the long side as I
have more than 100 frames. (each frame is 128x128x22).
It seems long to me next I was going to dump the indices of the ROI and
simply use buffer arithmetic to get the values out. But before getting my
hands dirty, is there something I am missing?
Is LabelImageToStatisticsLabelMapFilter recreating the objectmap from
labelimage each time the filter updates, even if this input is unchanged?
(that would be expensive and wasteful for this particular purpose as it
only needs to do this once, since the label does not change between these
100 frames).
Any other suggestions appreciated!
LabelStatisticsImageFilter is giving me the same performance.
Thanks
Soren
//iterate dim4 in 4D image
for (size_t iframe=0;iframe<xydims[3];iframe++)
{
//make the floatimage pointer point to the next frame (I guess
I could do this with SetRegion too??)
float3dimage->GetPixelContainer()->SetImportPointer(static_cast<float
*>(imgbuffers[0]->Buffer()+4*xydims[0]*xydims[1]*xydims[2]*iframe),xydims[0]*xydims[1]*xydims[2]);
float3dimage->Modified();
objlabelstatsfilter->Update();
for(unsigned int i = 0; i <
objlabelstatsfilter->GetOutput()->GetNumberOfLabelObjects(); ++i)
{
objlabelstatsfiltertype::OutputImageType::LabelObjectType* labelObject
= objlabelstatsfilter->GetOutput()->GetNthLabelObject(i);
std::cout << labelObject->GetMean() << std::endl;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130210/60e1536b/attachment.htm>
More information about the Insight-users
mailing list