title: Renderscript Mosaic effect
body: <p>I'm trying to think of a way to implement a mosaic effect with renderscript as a learning exercise but I can't find enough information to know which of these methods, if any, will work.</p>
  
  <ol>
  <li><p>Split a bitmap into n x n pixel sub-bitmaps. Run each sub-bitmap through a script that averages the value all pixels, then rejoin the bitmaps back into one in java. I worry that using forEach_root may result in concurrency issues if different pixels are updating the same global variable at the same time. I could use a loop to iterate through each pixel in the sub-bitmap to avoid concurrency issues, but then I would lose the benefit of forEach_root.</p></li>
  <li><p>Keep the original bitmap intact and run forEach_root. In the script, if I can know the coordinates of the element, I could figure out which square the pixel should be in and then add each pixel to the relative (0,0) for the square in which it resides.</p></li>
  <li><p>If I can create an allocation that only includes select pixels then I can have one pixel for each mosaic square and add each other pixel in that square to the representative pixel. This will avoid concurrency issues (if they exist), while still allowing multiple simultanious executions</p></li>
  </ol>
  
  <p>I really like number 3, but I'm not sure if such an allocation can be created. Alternatively, If collisions resulting from different renderscript threads accessing the same variable at the same time are handled gracefully then method one or two are probably easier.</p>