Community
cancel
Showing results for
Did you mean: Beginner
92 Views

## Confused with planar images

Hi,
I have searched the forums and docs but I'm still confused with planar images. My specific question is about a 3 plane 4:1:1 image construct. How is this layed out in memory? Is the Y plane 4 bytes long? Is it y1, y2 , y3, y4?
I am usingippiYCbCr422ToYCbCr411_8u_C2P3R to convert.
this is how i'm creating my 4:1:1 image;
[cpp] m_numChannels = 3; IppiSize chromaSize = { m_size.width/4, m_size.height }; m_channels = ippiMalloc_8u_C4( m_size.width, m_size.height, &(m_stepBytes) ); m_channelSize = m_size; m_channels = ippiMalloc_8u_C1( chromaSize.width, chromaSize.height, &(m_stepBytes) ); m_channelSize = chromaSize; m_channels = ippiMalloc_8u_C1( chromaSize.width, chromaSize.height, &(m_stepBytes) ); m_channelSize = chromaSize;[/cpp]
Thanks!
1 Solution Employee
92 Views

Hello,

The Planar (P)and channel (C) descriptors inippiYCbCr422ToYCbCr411_8u_C2P3R means covert 2 channeldata to 3 planar data, which
Y planar , which is a matrix withm_size.widthx m_size.height
Cb planar, which is a matrix with m_size.width/4 x m_size.height
Cr planar, which is a matrix with m_size.width/4 x m_size.height.

If consider tomalloc continousmemory , then 1 planar (widthxheight) image = 1 channel (widthxheigh) image. So if you use ippiMalloc, you can use

m_numChannels = 3;
IppiSize chromaSize = { m_size.width, m_size.height };
m_channels = ippiMalloc_8u_C1( m_size.width, m_size.height, &(m_stepBytes) ); m_channels = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes]));
m_channels = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes) );

Best Regards,
Ying

A similiar example are under ippiMallocin ipp Reference manual.

The function ippiMalloc is declared in the ippi.h file. This function allocates a memory block aligned to a 32-byte boundary for elements of different data types. Every line of the image is aligned in accordance with the pStepBytes parameter, which is calculated by the ippiMalloc function and returned for further use.

The function ippiMalloc allocates one continuous memory block, whereas functions that operate on planar images require an array of separate pointers (IppType* plane) to each plane as input. The ippiMalloc function should be called three times in this case. The code ExampleSetting Values to Pointers to Image Planes demonstrates how to construct such an array and set correct values to the pointers to use the allocated memory block with the Intel IPP functions operating on planar images. Note that pStepBytes should be specified for each plane. The example is given for 8u data type.

## Setting Values to Pointers to Image Planes

`int stepBytes;`
`Ipp8u* plane;`
`   plane = ippiMalloc_8u_C1(widthPixels, heightPixels,`
`                               &(stepBytes ));`
`   plane = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,`
`                               &(stepBytes ));`
`   plane = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,`
`                               &(stepBytes ));`
5 Replies Employee
92 Views Beginner
92 Views
Hi!
Thanks, Beginner
92 Views
Hi, ok, thanks, I found it in the help and I have already read it. My question remains. Should I be allocting this way?
[bash]m_numChannels = 3; IppiSize chromaSize = { m_size.width, m_size.height }; m_channels = ippiMalloc_8u_C4( m_size.width, m_size.height, &(m_stepBytes) ); m_channelSize = m_size; m_channels = ippiMalloc_8u_C2( m_size.width/4, m_size.height, &(m_stepBytes) ); m_channelSize = chromaSize; m_channels = ippiMalloc_8u_C2( m_size.width/4, m_size.height, &(m_stepBytes) ); m_channelSize = chromaSize;[/bash] Employee
93 Views

Hello,

The Planar (P)and channel (C) descriptors inippiYCbCr422ToYCbCr411_8u_C2P3R means covert 2 channeldata to 3 planar data, which
Y planar , which is a matrix withm_size.widthx m_size.height
Cb planar, which is a matrix with m_size.width/4 x m_size.height
Cr planar, which is a matrix with m_size.width/4 x m_size.height.

If consider tomalloc continousmemory , then 1 planar (widthxheight) image = 1 channel (widthxheigh) image. So if you use ippiMalloc, you can use

m_numChannels = 3;
IppiSize chromaSize = { m_size.width, m_size.height };
m_channels = ippiMalloc_8u_C1( m_size.width, m_size.height, &(m_stepBytes) ); m_channels = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes]));
m_channels = ippiMalloc_8u_C1( m_size.width/4, m_size.height, &(m_stepBytes) );

Best Regards,
Ying

A similiar example are under ippiMallocin ipp Reference manual.

The function ippiMalloc is declared in the ippi.h file. This function allocates a memory block aligned to a 32-byte boundary for elements of different data types. Every line of the image is aligned in accordance with the pStepBytes parameter, which is calculated by the ippiMalloc function and returned for further use.

The function ippiMalloc allocates one continuous memory block, whereas functions that operate on planar images require an array of separate pointers (IppType* plane) to each plane as input. The ippiMalloc function should be called three times in this case. The code ExampleSetting Values to Pointers to Image Planes demonstrates how to construct such an array and set correct values to the pointers to use the allocated memory block with the Intel IPP functions operating on planar images. Note that pStepBytes should be specified for each plane. The example is given for 8u data type.

## Setting Values to Pointers to Image Planes

`int stepBytes;`
`Ipp8u* plane;`
`   plane = ippiMalloc_8u_C1(widthPixels, heightPixels,`
`                               &(stepBytes ));`
`   plane = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,`
`                               &(stepBytes ));`
`   plane = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,`
`                               &(stepBytes ));` Beginner
92 Views
Thanks for the clarification! 