Inco

how can i use read/write buffer?

Discussion created by Inco on Dec 22, 2008
Latest reply on Dec 22, 2008 by Inco
How can I write kernel with the Brook+, which makes the buffer to read and write?

How can I write kernel with the Brook+, which makes the buffer to read and write?

I have: image(704x576) and logical grid(22x18(edge=32)) on this image - one grid cell goups 32x32 pixel under it.

I need to proccess image, and calc (for example) number of red pixels (color.R > 200, for example) in every cell, BUT in this kernel i want mark all pixel to green (color.G = 255);

Show the code:

brook::Stream<int> img(...);  // 704x576
brook::Stream<int> res(...);  // 704x576
brook::Stream<int> mask(...);    // edge=32 -> (704/edge)x(576/edge) -> 22x18
...   
Kernel1(img, mask, res);    // sart thread for every pixel

kernel void Kernel1(int frame[][], int mask[][], out int outputFrame<>
{       
    int xMask = vPos.x / edge;   
    int yMask = vPos.y / edge;   
    int2 maskPos = int2(xMask, yMask);  // index of grid cell when current pixel is located

    int color = frame[instance().xy];    // current pixel
    int red = color & 0xFF;                // get r-channel
    if (red > 200)
        mask[maskPos]++;
   
    outputFrame = color | 0x00FF0000;   
}

 

can i make it work?

Outcomes