1 Reply Latest reply on Apr 12, 2013 3:04 AM by shreedhar_pawar

    Error in processing Image pixel values in a float4[image_size] array.

    shreedhar_pawar

      what is wrong with the code given below... Can we declare a float4 array of a  big size(within the limits of float of course)... and access it as min_weight_arr.x[id] as i've done below , or is there another way of accessing that element..? I have also inserted the error below

       

       

      __kernel void image_test(__read_only image2d_t srcImg,

                                           __write_only image2d_t dstImg,

                                    sampler_t sampler,

                                    int width, int height,

                                                                              __global float4* src_arr,    //8*width*height

                                                                              __global float4* dest_arr,   //8*width*height

                                                                              __global float4* weight_arr,  //8*width*heigh

                                                                               __global float4* min_src_arr,

                                                                              __global float4* min_dest_arr,__global float4* min_weight_arr)  //width*height

      {

        

                float4 temp;

                uint i;

                uint x= get_global_id(0);

                uint y=get_global_id(1);

                unsigned int id=((width*x)+y);

       

                float4 p=(read_imagef(srcImg, sampler, (int2)(x, y)))*255;

          float4 p1=(read_imagef(srcImg, sampler, (int2)(x-1, y-1)))*255;

                float4 p2=(read_imagef(srcImg, sampler, (int2)(x-1, y)))*255;

                float4 p3=(read_imagef(srcImg, sampler, (int2)(x-1, y+1)))*255;

                float4 p4=(read_imagef(srcImg, sampler, (int2)(x, y-1)))*255;

                float4 p5=(read_imagef(srcImg, sampler, (int2)(x, y+1)))*255;

                float4 p6=(read_imagef(srcImg, sampler, (int2)(x+1, y-1)))*255;

                float4 p7=(read_imagef(srcImg, sampler, (int2)(x+1, y)))*255;

                float4 p8=(read_imagef(srcImg, sampler, (int2)(x+1, y+1)))*255;

       

       

                src_arr[8*id]=id;

                weight_arr[8*id]=p-p1;

                dest_arr[8*id]=((width*(x-1))+(y-1));

       

       

                src_arr[(8*id)+1]=id;

                weight_arr[(8*id)+1]=p-p2;

                dest_arr[(8*id)+1]=((width*(x-1))+(y));

       

       

          src_arr[(8*id)+2]=id;

                weight_arr[(8*id)+2]=p-p3;

                dest_arr[(8*id)+2]=((width*(x-1))+(y+1));

          

                src_arr[(8*id)+3]=id;

                weight_arr[(8*id)+3]=p-p4;

                dest_arr[(8*id)+3]=((width*(x))+(y-1));

       

       

          src_arr[(8*id)+4]=id;

                weight_arr[(8*id)+4]=p-p5;

                          dest_arr[(8*id)+4]=((width*(x))+(y-1));

       

       

          src_arr[(8*id)+5]=id;

                weight_arr[(8*id)+5]=p-p6;

                dest_arr[(8*id)+5]=((width*(x+1))+(y-1));

       

       

                 src_arr[(8*id)+6]=id;

                weight_arr[(8*id)+6]=p-p7;

                          dest_arr[(8*id)+7]=((width*(x+1))+(y));

       

       

          src_arr[(8*id)+7]=id;

                weight_arr[(8*id)+7]=p-p8;

                          dest_arr[(8*id)+7]=((width*(x+1))+(y+1));

       

       

                temp.x=weight_arr.x[8*id];

                for(i=((8*id)+1);i<((8*id)+8);i++)

                  {

                           if (weight_arr.x[i]<temp.x)

                            {

                                      temp.x=weight_arr[i].x;

                                min_weight_arr.x[id]=temp.x;

                                min_src_arr.x[id]=src_arr.x[i];

                                min_dest_arr.x[id]=dest_arr.x[i];

                            }

                  }

                if (temp.x==weight_arr.x[8*id])

                 {

                   min_src_arr.x[id]=src_arr.x[8*id];

                   min_weight_arr.x[id]=temp.x;

                    min_dest_arr.x[id]=dest_arr.x[8*id];

                 }

       

       

      }

      Error :

       

      Imagetest.PNG