i have opened image in app , getting pixels data of image using following piece of code.
using (irandomaccessstream filestreams = await file.openasync(windows.storage.fileaccessmode.read)) { bitmapdecoder decoder = await bitmapdecoder.createasync(filestreams); bitmaptransform transform = new bitmaptransform() { scaledwidth = convert.touint32(bitmapimage.pixelwidth), scaledheight = convert.touint32(bitmapimage.pixelheight) }; pixeldataprovider pixeldata = await decoder.getpixeldataasync( bitmappixelformat.bgra8, bitmapalphamode.straight, transform, exiforientationmode.ignoreexiforientation, colormanagementmode.donotcolormanage ); byte[] sourcepixels = pixeldata.detachpixeldata(); }
here have got array of pixels of image. total number of pixels in array (width * height * 4). after analyzing array came know index numbers 0, 1, 2 , 3 contains red, green blue , alpha values of first pixel, index numbers 4, 5, 6 , 7 contains red, green, blue , alpha values of second pixel of image , on.
now want apply 3x3 filter image, how can 1-d array? know how if have 2-d array of image.
right now, have 1 idea in mind.
- store red pixels in 1 2d array, green in other , on
- apply filter on each 2d array.
- combine of these make 1-d array again , return result.
is solution? me if there better solution it.
Comments
Post a Comment