[Insight-users] Itk and OpenCV

Hauke Heibel heibel at cs.tum.edu
Fri Apr 11 11:13:24 EDT 2008


Hi Flo,

I have worked a lot with OpenCV and many of my colleagues from the CV 
department still do. First of all you have to note that OpenCV's focus 
is CV and thus they provide (at least as far as I know) only algorithms 
that will work in 2D. ITK on the other hand side has plenty of 
algorithms that do out of the box work in ND.

In general working with OpenCV should be possible and you might want to 
take a look at the itk::ImportImageFilter (OpenCV -> ITK) and the 
function cvCreateImageHeader (ITK -> OpenCV).

You should be aware of the fact that OpenCV (the same holds for the IPP 
library) usually adds a padding to its image's rows, since SIMD 
instructions require memory aligned data (for maximal speed gain). 
Again, as far as I know ITK does not do this. So whenever you are using 
a pointer to an itk::Image's buffer within an IplImage created by 
cvCreateImageHeader, you have to make sure that the required padding is 
zero (widthStep should be equal to sizeof(T)*width). If I remember 
correctly, OpenCV will pad such that each image row's number of bytes is 
a multiple of four - but I may be wrong here. It's some time ago since I 
used it on an every day basis. Since medical images are oftentimes power 
2 images you will probably have to align the memory only in rare cases. 
Whenever you start to work on image regions on the other hand side you 
should be careful.

That is all of the pitfalls I can think of for now. I hope this is of 
help and wish you good luck. ;)

Regards,
Hauke

Flo wrote:
>
> Dear all:
>
> I am quite familiar with ITK. However, and despite the greatness (I’m 
> sincerely thanking any contributors here) of its content, I’m looking 
> forward to speeding up my applications now.
>
> As such, I introduced Trilinos for every matrix linear calculation I 
> needed.
>
> As well, I would like to introduce another framework that could speed 
> up basic filters such as erosion / dilatation / region growing as I 
> feel ITK is a tide slow in these areas.
>
> My architecture is Linux/Windows on Intel platform with a Quadcore. As 
> such, I had a look at Intel OpenCV and Intel IPP (as a side note, it 
> is funny to see that Intel provide the IPP for free under Linux only 
> if it’s for non-commercial usage of any kind and/or non-funded 
> development of any kind – stating that a student’s internship falls 
> into commercial usage as at least the university gets funds from the 
> government).
>
> Thus, and before starting recoding part of my applications, I would 
> appreciate the feedbacks of any ITK user as per mixing OpenCV with ITK 
> regarding a potential speed gain.
>
> As well, is there any other way to speed up ITK for basic algorithm if 
> combined with another framework.
>
> My end goal is to have a fast Expectation-Maximization Code for image 
> segmentation without the trouble of converting an itkImage into a 
> Vector and then to a List to finally feed the EM algorithm, a process 
> that takes lots of time to my understanding.
>
> Thanks for any info.
>
> Flo.
>
-- 
Tim Hauke Heibel
Computer Aided Medical Procedures (CAMP)
fon: +49 89 289 19427
fax: +49 89 289 17059



More information about the Insight-users mailing list