Friday, 15 April 2011

android - Renderscript Mosaic effect -



android - Renderscript Mosaic effect -

i'm trying think of way implement mosaic effect renderscript learning exercise can't find plenty info know of these methods, if any, work.

split bitmap n x n pixel sub-bitmaps. run each sub-bitmap through script averages value pixels, rejoin bitmaps 1 in java. worry using foreach_root may result in concurrency issues if different pixels updating same global variable @ same time. utilize loop iterate through each pixel in sub-bitmap avoid concurrency issues, lose benefit of foreach_root.

keep original bitmap intact , run foreach_root. in script, if can know coordinates of element, figure out square pixel should in , add together each pixel relative (0,0) square in resides.

if can create allocation includes select pixels can have 1 pixel each mosaic square , add together each other pixel in square representative pixel. avoid concurrency issues (if exist), while still allowing multiple simultanious executions

i number 3, i'm not sure if such allocation can created. alternatively, if collisions resulting different renderscript threads accessing same variable @ same time handled gracefully method 1 or 2 easier.

here's bit different idea; want create 4x4 mosaic 256x256 image;

create 64x64 allocation store each mosaic piece color.

run foreach on 64x64 allocation , set original 256x256 allocation parameter it.

within each foreach iteration calculate ie. average color original image 4x4 area mosaic piece corresponds to.

run foreach on original 256x256 allocation , give calculated 64x64 parameter.

within each foreach iteration set color 1 corresponding 64x64 allocation.

i believe approach should adjust rather different shaped , sized mosaics too. overhead of temporary allocation only.

android image-processing renderscript

No comments:

Post a Comment