Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community Forums
- :
- Forums
- :
- Software Development and Acceleration
- :
- HLS
- :
- Implementation of math fucntions on a matrix

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

meany2195

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-23-2019 09:31 PM

994 Views

Registered:
01-23-2019

Iam trying to implement abs function on a matrix in the top function. i need to create an IP of it. abs function is working fine on a complex number but cannot be implemented on a matrix.

This is a snippet of my top function:

**void sos(unit8_t image_in[300*200], unit8_t image_out[300*200])**

**{**

** hls::Mat<200,300,HLS_8UC1> src;**

** hls::AXIM2Mat<300,uint8_t,200,300,HLS_8UC1>(image_in,src);**

** hls::Mat<200,300,HLS_8UC1> abs(src);**

** hls::Mat2AXIM<300,uint8_t,200,300,HLS_8UC1>(src,image_out);**

**}**

Can anyone please tell if this code can be implement as shown above or if i need to define a stream for the matrices or convert the matrix to array to implement math functions on them.

1 Solution

Accepted Solutions

Highlighted

tedbooth

Voyager

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-24-2019 01:27 PM

958 Views

Registered:
03-28-2016

You likely need to use the openCV fucntion absDiff. Create a MAT full of zeros for one of the inputs. Check UG1233 (Xilinx OpenCV User Guide).

Ted Booth - Tech. Lead FPGA Design Engineer

www.designlinxhs.com

www.designlinxhs.com

6 Replies

Highlighted

tedbooth

Voyager

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-24-2019 01:27 PM

959 Views

Registered:
03-28-2016

You likely need to use the openCV fucntion absDiff. Create a MAT full of zeros for one of the inputs. Check UG1233 (Xilinx OpenCV User Guide).

Ted Booth - Tech. Lead FPGA Design Engineer

www.designlinxhs.com

www.designlinxhs.com

Highlighted
##

Jump to solution

meany2195

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-25-2019 02:26 AM

939 Views

Registered:
01-23-2019

Re: Implementation of math fucntions on a matrix

Thank you sir for your response.

I considered your advice and used absDiff by creating a matrix of zeros. But on the application of absDiff on two different images and the application of absDiff on an image and a zero matrix, the outputs seems to be contradictory.

On applying absDiff as adviced, the output image must be the same as input, since the input image is a matrix of real numbers. But contradictory to this fact, the output obtained by me is a image with distorted dots distributed around as shown in the image attached below.

This was how i implemented the function, it would be very helpful if you could say where am I going wrong.

**hls::AbsDiff(src1,src2,dst);**

where src1-input image matrix, src2-zero matrix and dst-output matrix.

Regards

Manisha Riyana

Highlighted
##

Jump to solution

tedbooth

Voyager

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-25-2019 07:03 AM

927 Views

Registered:
03-28-2016

Re: Implementation of math fucntions on a matrix

Off hand, I'm not sure why the output would look like that. The output MAT may need to be pre-allocated before the absDiff is performed. I'd have to see the code to get a better idea.

Ted Booth - Tech. Lead FPGA Design Engineer

www.designlinxhs.com

www.designlinxhs.com

Highlighted
##

Jump to solution

meany2195

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-31-2019 12:57 AM

873 Views

Registered:
01-23-2019

Re: Implementation of math fucntions on a matrix

AbsDiff function works perfectly fine while using a blank image. but when i try to generaate a blank matrix using

**void Zero(hls::Mat<200,300,HLS_8UC1>&src);**

I cannot apply AbsDiff on this matrix and the image i had taken as input.

Highlighted
##

Jump to solution

meany2195

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-31-2019 08:51 PM

814 Views

Registered:
01-23-2019

Re: Implementation of math fucntions on a matrix

I have found the solution to my problem by myself.

To implement the math functions on top function, we need to first convert the matrix into a single dimensional array and then apply the mat function on individual elements of the array.

Here's the code snippet of implementing abs function on an image:

void **conv**(uint8_t image_in[64*64],uint8_t image_out[64*64])

{

hls::Mat<64,64,HLS_8UC1> src;

hls::Mat<64,64,HLS_8UC1> dst;

hls::AXIM2Mat<64,uint8_t,64,64,HLS_8UC1>(image_in,src);

uint16_t hmap2_array[64*64];

uint16_t Ar[64*64];

hls::Mat2Array<64>(src,hmap2_array);

for(int i=0;i<4096;i++)

{

Ar[i]=**abs**(hmap2_array[i]);

}

hls::Array2Mat<64>(Ar, dst);

hls::Mat2AXIM<64,uint8_t,64,64,HLS_8UC1>(dst,image_out);

}

Highlighted
##

Jump to solution
Thanks a lot. I got the required info. Also integation is useful to get more information about math functions.

dragontattoo

Newbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-04-2019 07:59 AM - edited 11-11-2019 10:11 PM

380 Views

Registered:
07-15-2019

Re: Implementation of math fucntions on a matrix