Error on Sobel edge detector

21 views
Skip to first unread message

David

unread,
Oct 11, 2018, 9:04:20 AM10/11/18
to Pluto development

My code relevant part looks like this:

#pragma scop
    for (x = 1; x < HEIGHT - 1 ; ++x) // iterate through image
    {
      for (y = 1; y < WIDTH - 1 ; ++y)
      {
        /* Don't work with PLUTO */
        /* Commented out
        pixel_x =     (sobel_x[0][0] * grayImage[x-1][y-1]) + (sobel_x[0][1] * grayImage[x][y-1]) + (sobel_x[0][2] * grayImage[x+1][y-1]) +
                (sobel_x[1][0] * grayImage[x-1][y])   + (sobel_x[1][1] * grayImage[x][y])   + (sobel_x[1][2] * grayImage[x+1][y])   +
                (sobel_x[2][0] * grayImage[x-1][y+1]) + (sobel_x[2][1] * grayImage[x][y+1]) + (sobel_x[2][2] * grayImage[x+1][y+1]);   

        pixel_y =     (sobel_y[0][0] * grayImage[x-1][y-1]) + (sobel_y[0][1] * grayImage[x][y-1]) + (sobel_y[0][2] * grayImage[x+1][y-1]) +
                (sobel_y[1][0] * grayImage[x-1][y])   + (sobel_y[1][1] * grayImage[x][y])   + (sobel_y[1][2] * grayImage[x+1][y])   +
                (sobel_y[2][0] * grayImage[x-1][y+1]) + (sobel_y[2][1] * grayImage[x][y+1]) + (sobel_y[2][2] * grayImage[x+1][y+1]);
       

        val = sqrt((pixel_x * pixel_x) + (pixel_y * pixel_y));
        val = val > 255 ? 255 : val < 0 ? 0 : val;

        grayImageSobel[x][y] = val;
        */

        /* work, but 3-4 times slower sequentially than the above one so after parallelization its almost run as fast as the above one sequentially */
        grayImageSobel[x][y] =     sqrt((PX_X(x,y) * PX_X(x,y)) + (PX_Y(x,y) * PX_Y(x,y))) > 255  ? 255  :
                                               sqrt((PX_X(x,y) * PX_X(x,y)) + (PX_Y(x,y) * PX_Y(x,y))) < 0     ? 0      :
                                               sqrt((PX_X(x,y) * PX_X(x,y)) + (PX_Y(x,y) * PX_Y(x,y)));
      }
    }
#pragma endscop

Macros:

#define        PX_X(x,y)    ((sobel_x[0][0] * grayImage[x-1][y-1])  + (sobel_x[0][1] * grayImage[x][y-1]) + (sobel_x[0][2] * grayImage[x+1][y-1]) + \
                                      (sobel_x[1][0] * grayImage[x-1][y])     + (sobel_x[1][1] * grayImage[x][y])    + (sobel_x[1][2] * grayImage[x+1][y])    + \
                                      (sobel_x[2][0] * grayImage[x-1][y+1]) + (sobel_x[2][1] * grayImage[x][y+1]) + (sobel_x[2][2] * grayImage[x+1][y+1]))

#define        PX_Y(x,y)    ((sobel_y[0][0] * grayImage[x-1][y-1])  + (sobel_y[0][1] * grayImage[x][y-1]) + (sobel_y[0][2] * grayImage[x+1][y-1]) + \
                                      (sobel_y[1][0] * grayImage[x-1][y])     + (sobel_y[1][1] * grayImage[x][y])    + (sobel_y[1][2] * grayImage[x+1][y])    + \
                                      (sobel_y[2][0] * grayImage[x-1][y+1]) + (sobel_y[2][1] * grayImage[x][y+1]) + (sobel_y[2][2] * grayImage[x+1][y+1]))

So my question is why PLUTO throws an error when I try to use the to commented out, better version? I may already found the answer from Uday's response to the previous question. "Cloog's input format
didn't (or still doesn't) allow local variables to be specified in domains". Do I understand this correctly? So the commented out version just couldn't work because of this?
Reply all
Reply to author
Forward
0 new messages