cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
3,646 Views
Registered: ‎12-08-2016

How to filetr the Max value from image frame array

Jump to solution

Hi Folks,

 

I am doing bottle Pine hole detection. In image is processing through HLS function and  in pin hole image has some values like [00 00 FF FF so on], 00 = black pixel, FF= white pixel. Here I need to filter Maximum value that is "FF". How to filter the Max value ?

 

Please suggest me regarding this.

 

Thanks and Best Regards

Vinod Sajjan

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Contributor
Contributor
5,215 Views
Registered: ‎03-13-2017

Hi @vinodsajjan

 

How do you declare pixIn and dilate? You have to use the same type. Like this:

 

hls::stream<ap_axiu<8,1,1>> dilate;

ap_axiu<8,1,1> pixIn;

 

Best regards,

Rosa Perez

View solution in original post

0 Kudos
10 Replies
Highlighted
Contributor
Contributor
3,633 Views
Registered: ‎03-13-2017

Hello! You can create a hls core with a input axi video stream and a output axi video stream. Then you can read axi input value and compare with max_value like this:

 

void maxValue(hls::stream<ap_axiu<24,1,1>> video_in,hls::stream<ap_axiu<24,1,1>> video_out, int max)

{

     ap_axiu<24,1,1> pixIn;

     int max_value=0;

 

#pragma HLS PIPELINE=1

 

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

    {

        pixIn=video_in.read();

        if(pixIn.range(23,0)>max_value)  max_value=pixIn.range(23,0);

        video_out.wite(pixIn);

    }

    max=max_value;    

}

 

Please mark this answer as solved if that is useful for you. Thanks

0 Kudos
Highlighted
Adventurer
Adventurer
3,618 Views
Registered: ‎12-08-2016

Hi @rosa_bpc,

 

Thank you for your support and time.

 

void maxValue(hls::stream<ap_axiu<24,1,1>> video_in,hls::stream<ap_axiu<24,1,1>> video_out, int max)

{

     ap_axiu<24,1,1> pixIn;

     int max_value=0;

 

#pragma HLS PIPELINE=1

 

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

    {

        pixIn=video_in.read();

        if(pixIn.range(23,0)>max_value)  max_value=pixIn.range(23,0);

        video_out.wite(pixIn);

    }

    max=max_value;    

}

 

 

Here, what indicates these two variable,Range and wite

 

Thanks and Best Regards

Vinod Sajjan

0 Kudos
Highlighted
Contributor
Contributor
3,607 Views
Registered: ‎03-13-2017

Hi! 

 

- range(23,0) is the value of bits since bit 0 to bit 23 (24 bits). You have 24 bits in your axi stream (ap_axiu<24,1,1>). If you want you can change the number of bit. 24 bits is necessary to rgb, however you can use other. 

 

- video_out.write(pixIn) (NO wite, I'm sorry, wite is an error) is to write pixIn into axi stream out.

 

Furhermore I forgot pragmas to specify that video_in and video_out are axi stream:

 

#pragma HLS INTERFACE axis port=video_in

#pragma HLS INTERFACE axis port=video_out

 

So this is the final code:

 

void maxValue(hls::stream<ap_axiu<24,1,1>> video_in,hls::stream<ap_axiu<24,1,1>> video_out, int max)

{

 

#pragma HLS INTERFACE axis port=video_in

#pragma HLS INTERFACE axis port=video_out

 

     ap_axiu<24,1,1> pixIn;

     int max_value=0;

 

#pragma HLS PIPELINE=1

 

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

    {

        pixIn=video_in.read();

        if(pixIn.range(23,0)>max_value)  max_value=pixIn.range(23,0);

        video_out.write(pixIn);

    }

    max=max_value;    

}

 

Best Regards

Rosa Perez

0 Kudos
Highlighted
Adventurer
Adventurer
3,602 Views
Registered: ‎12-08-2016

Hi @rosa_bpc,

 

Thank you for your time and support.

 

I am using 8 bit input image, because of that i am using range(7,0); but for range showing error.

 

Please suggest me regarding this.

 

Thanks and Best Regards

Vinod Sajjan

 

0 Kudos
Highlighted
Contributor
Contributor
3,600 Views
Registered: ‎03-13-2017

Hi @vinodsajjan

 

Could you put here your code and your error please?

 

Best regards,

Rosa Perez

0 Kudos
Highlighted
Adventurer
Adventurer
3,597 Views
Registered: ‎12-08-2016

Hi @rosa_bpc,

 

Thank you For your support and time.

 

I am pasting my code.

 

    #pragma HLS PIPELINE=1

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

    {

        pixIn=dilate.read();

        if(pixIn.range(7,0)>max_value)  max_value=pixIn.range(7,0);

        output_data.write(pixIn);

    }

 

for range showing bug sign.

 

Thanks and Best Regards

Vinod Sajjan

0 Kudos
Highlighted
Contributor
Contributor
3,594 Views
Registered: ‎03-13-2017

Hi @vinodsajjan,

 

I'm sorry, it is wrong, it is not pixIn.range(7,0), it is pixIn.data.range(7,0). I forgot write ".data"

 

Best regards 

Rosa Perez

0 Kudos
Highlighted
Contributor
Contributor
3,593 Views
Registered: ‎03-13-2017

Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution. Thanks

0 Kudos
Highlighted
Adventurer
Adventurer
3,576 Views
Registered: ‎12-08-2016

Hi @rosa_bpc,

 

Thank you for your support.

 

I am pasting here my code and still getting error.

 

#pragma HLS PIPELINE=1

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

    {
        pixIn=dilate.read();
        if(pixIn.data.range(7,0)>max_value)
        max_value=pixIn.data.range(7,0);
        output_data.write(pixIn);
    }
    max=max_value;
                        if(max>0)
                            {
                            Result=1;
                                //printf("hole detected\n");
                            }
                            else
                            {
                                Result=0;
                                //printf("no hole detected\n");
                            }

 

I am getting error for this

error: no match for 'operator=' in 'pixIn = dilate.hls::Mat<ROWS, COLS, T>::read [with int ROWS = 480, int COLS = 752, int T = 0, typename Type<(T & ((1 << 4) - 1))>::name = unsigned char]()'

 

How to fix above error please suggest me.

 

Thanks and Best Regards

Vinod Sajjan

0 Kudos
Highlighted
Contributor
Contributor
5,216 Views
Registered: ‎03-13-2017

Hi @vinodsajjan

 

How do you declare pixIn and dilate? You have to use the same type. Like this:

 

hls::stream<ap_axiu<8,1,1>> dilate;

ap_axiu<8,1,1> pixIn;

 

Best regards,

Rosa Perez

View solution in original post

0 Kudos