Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Concatenate images side by side

Bouchan__Thomas
Beginner
566 Views

Hi, 

I am new to IPP libraries and I'd like to concatenate 4 images to get one bigger one. From 4 images of size 256*256, I'd like to make one of size 512*512. 

How is it possible? I guess that playing with ROI could be possible but I can't figure out how. I had a look at Set and Copy functions but Set only works for constants values, and Copy only for source and destination images of the same size if I understand it well.

Thanks for you help,

Thomas

0 Kudos
1 Solution
Andrey_B_Intel
Employee
567 Views

Hi Thomas.

Welcome to IPP!

The most of IPP image processing functions process images inside rectangular region of interest "roiSize" using  steps "srcStep/dstStep" inside input and output images between lines.

According with API ippiCopy_8u_C1R( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep,IppiSize roiSize )  the pseudo code will be

roiSize.width = 256; roiSize.height = 256;

srcStep= 256;

dstStep = 512;

ippiCopy_8u_C1R( pSrc0, srcStep,  pDst, dstStep, roiSize );   // copy left-up image

ippiCopy_8u_C1R( pSrc1, srcStep,  pDst+roiSize.width, dstStep, roiSize );//copy right-up image

ippiCopy_8u_C1R( pSrc2, srcStep,  pDst+dstStep*roiSize.height, dstStep, roiSize );   //copy left-down image

ippiCopy_8u_C1R( pSrc3, srcStep,  pDst+dstStep*roiSize.height+roiSize.width, dstStep, roiSize );   // copy right-down image

 Thanks.

 

View solution in original post

0 Kudos
5 Replies
Andrey_B_Intel
Employee
568 Views

Hi Thomas.

Welcome to IPP!

The most of IPP image processing functions process images inside rectangular region of interest "roiSize" using  steps "srcStep/dstStep" inside input and output images between lines.

According with API ippiCopy_8u_C1R( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep,IppiSize roiSize )  the pseudo code will be

roiSize.width = 256; roiSize.height = 256;

srcStep= 256;

dstStep = 512;

ippiCopy_8u_C1R( pSrc0, srcStep,  pDst, dstStep, roiSize );   // copy left-up image

ippiCopy_8u_C1R( pSrc1, srcStep,  pDst+roiSize.width, dstStep, roiSize );//copy right-up image

ippiCopy_8u_C1R( pSrc2, srcStep,  pDst+dstStep*roiSize.height, dstStep, roiSize );   //copy left-down image

ippiCopy_8u_C1R( pSrc3, srcStep,  pDst+dstStep*roiSize.height+roiSize.width, dstStep, roiSize );   // copy right-down image

 Thanks.

 

0 Kudos
Adriaan_van_Os
New Contributor I
567 Views

Would that be faster than using e.g. memmove, memcpy or vm_copy ?

Regards,

Adriaan van Os

0 Kudos
Bouchan__Thomas
Beginner
567 Views

Hi Andrey,

Thanks for your quick reply. I was missing the real meaning of the dstStep parameter, indeed.

Using your code, I fixed my problem. However as I am working with Ipp32f type, it's not dstStep in bytes which has to be used but in terms of pixels. It can be confusing to call it dstStep as in the documentation this variable means the step in unit of bytes.

Thanks again!

0 Kudos
Andrey_B_Intel
Employee
567 Views

Adriaan van Os wrote:

Would that be faster than using e.g. memmove, memcpy or vm_copy ?

I hope yes because ippiCopy uses  ippsCopy that is optimized.

0 Kudos
Adriaan_van_Os
New Contributor I
567 Views

I hope yes because ippiCopy uses  ippsCopy that is optimized.

Interesting. I looked at the source code of glibc's memcpy c.s. They don't seem to be vectorized. Unless, maybe, the compiler builtin_memcpy is used. But I can't find that either gcc or llvm vectorizes them.

The Intel compiler has intel_fast_memcpy c.s. https://software.intel.com/en-us/articles/memcpy-memset-optimization-and-control.

That suggests that it would pay to replace memcpy c.s. with ippsCopy/ippsMove for n > .....

Regards,

Adriaan van Os

0 Kudos
Reply