Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
4 Views

How to build a reflective border of a matrix?

Hello,

I have a matrix A of size mxn. I would like to make a reflective border around the boundary of matrix A. Could you please let me know how to do it by using Intel IPP?

Thank you very much,

Guangyi Chen
0 Kudos
8 Replies
Highlighted
Valued Contributor II
4 Views

>>...matrix A of size mxn...

It's clear.

>>...a reflective border around the boundary of matrix A...

Sorry, I didn't understand your question. What is a reflective border?

Do youwant to do somethingwith a matrix usingclassic Reflection Operations of theLinear Algebra?

0 Kudos
Highlighted
New Contributor II
4 Views

Hi,

if it's about image processing - you can use the next functions:

/* ////////////////////////////////////////////////////////////////////////////

// Name: ippiCopyReplicateBorder

//

// Purpose: Copies pixel values between two buffers and adds

// the replicated border pixels.

//

// Returns:

// ippStsNullPtrErr One of the pointers is NULL

// ippStsSizeErr 1). srcRoiSize or dstRoiSize has a field with negative or zero value

// 2). topBorderHeight or leftBorderWidth is less than zero

// 3). dstRoiSize.width < srcRoiSize.width + leftBorderWidth

// 4). dstRoiSize.height < srcRoiSize.height + topBorderHeight

// ippStsStepErr srcStep or dstStep is less than or equal to zero

// ippStsNoErr OK

//

// Parameters:

// pSrc Pointer to the source image buffer

// srcStep Step in bytes through the source image

// pDst Pointer to the destination image buffer

// dstStep Step in bytes through the destination image

// scrRoiSize Size of the source ROI in pixels

// dstRoiSize Size of the destination ROI in pixels

// topBorderHeight Height of the top border in pixels

// leftBorderWidth Width of the left border in pixels

*/

/* ////////////////////////////////////////////////////////////////////////////

// Name: ippiCopyConstBorder

//

// Purpose: Copies pixel values between two buffers and adds

// the border pixels with constant value.

//

// Returns:

// ippStsNullPtrErr One of the pointers is NULL

// ippStsSizeErr 1). srcRoiSize or dstRoiSize has a field with negative or zero value

// 2). topBorderHeight or leftBorderWidth is less than zero

// 3). dstRoiSize.width < srcRoiSize.width + leftBorderWidth

// 4). dstRoiSize.height < srcRoiSize.height + topBorderHeight

// ippStsStepErr srcStep or dstStep is less than or equal to zero

// ippStsNoErr OK

//

// Parameters:

// pSrc Pointer to the source image buffer

// srcStep Step in bytes through the source image

// pDst Pointer to the destination image buffer

// dstStep Step in bytes through the destination image

// srcRoiSize Size of the source ROI in pixels

// dstRoiSize Size of the destination ROI in pixels

// topBorderHeight Height of the top border in pixels

// leftBorderWidth Width of the left border in pixels

// value Constant value to assign to the border pixels

*/

/* ////////////////////////////////////////////////////////////////////////////

// Name: ippiCopyWrapBorder

//

// Purpose: Copies pixel values between two buffers and adds the border pixels.

//

// Returns:

// ippStsNullPtrErr One of the pointers is NULL

// ippStsSizeErr 1). srcRoiSize or dstRoiSize has a field with negative or zero value

// 2). topBorderHeight or leftBorderWidth is less than zero

// 3). dstRoiSize.width < srcRoiSize.width + leftBorderWidth

// 4). dstRoiSize.height < srcRoiSize.height + topBorderHeight

// ippStsStepErr srcStep or dstStep is less than or equal to zero

// ippStsNoErr OK

//

// Parameters:

// pSrc Pointer to the source image buffer

// srcStep Step in bytes through the source image

// pDst Pointer to the destination image buffer

// dstStep Step in bytes through the destination image

// scrRoiSize Size of the source ROI in pixels

// dstRoiSize Size of the destination ROI in pixels

// topBorderHeight Height of the top border in pixels

// leftBorderWidth Width of the left border in pixels

*/

Regards,
Igor

0 Kudos
Highlighted
Employee
4 Views

Hi,
Border pixels reflection is a "mirror" border type in IPP. Imagine we've got vector of the len 5 with elements: "1 2 3 4 5" and we whould like to get mirrororedborder in the lenght of 2. Then in result of it we obtain vector in the len of 9 with the elements "3 2 1 2 3 4 5 4 3". So in case of matrixes you need to relflect every row, then reflect every column.
0 Kudos
Highlighted
Valued Contributor II
4 Views

>>...relflect every row, then reflect every column...

- Use ippiCopyReplicateBorder for rows
- Transpose a matrix
- Use ippiCopyReplicateBorder for rows
- Transpose a matrix

In case of a matrixcould itbe done in this way?
0 Kudos
Highlighted
New Contributor II
4 Views

ippiCopyReplicateBorder does replication both for columns and rows - no need to perform transposition


Regards,
Igor
0 Kudos
Highlighted
Valued Contributor II
4 Views

How does it deal withcorners of the matrix?

If a length is 2 at every corner there are 4values ( 2x2 block )and I wonder how these values will
be calculated?

Best regards,
Sergey
0 Kudos
Highlighted
Employee
4 Views

Hi,
Please note, that this function replicates boundary pixels: not reflects them. Let the input matrix 2x2 will be the following:
1 2
34
And we would like to get border in the length of 1. So after this function call you will get the following 4x4 matrix:
1 12 2
1 12 2
334 4
334 4
0 Kudos
Highlighted
Valued Contributor II
4 Views

Thank you, Igor! This is exactly what I wanted to understand:

All corner values in the new matrixare replicated, not calculated.

Best regards,
Sergey
0 Kudos