java - How to display histogram of RGB values of an image? -


my application captures image , applies filter modify image rgb values.

once modified, wish display histogram of each colour (red, green, blue) on top of image itself.

i know how rgb values , know how bitmap, dont know how plot them.

code rgb values:

    int[] pixels = new int[width*height];     int index = 0;     image.getpixels(pixels, 0, width, 0, 0, width, height);     bitmap returnbitmap = bitmap.createbitmap(width, height,             bitmap.config.argb_8888);      (int x = 0; x < width; x++) {         (int y = 0; y < height; y++) {             = (pixels[index] >> 24) & 0xff;             r = (pixels[index] >> 16) & 0xff;             g = (pixels[index] >> 8) & 0xff;             b = pixels[index] & 0xff;                             ++index;                       }             } 

we had done similar. got bitmap of image with:

bitmap bmp = bitmapfactory.decoderesource(<youimageview>.getresources(), r.drawable.some_drawable); 

we iterated on every pixel , used following piece of code colors of pixel:

int color = bmp.getpixel(i, j); int[] rgbvalues = new int[]{                 (color >> 16) & 0xff, //red                 (color >>  8) & 0xff, //green                 (color      ) & 0xff  //blue             }; 

edit:
read can opacity using insead:

int color = bmp.getpixel(i, j); int[] rgbvalues = new int[]{                 (color >> 24) & 0xff, //alpha                 (color >> 16) & 0xff, //red                 (color >>  8) & 0xff, //green                 (color      ) & 0xff  //blue             }; 

if have values, recommend androidplot create graphs. there examples make easy use. haven't worked bar-charts, line charts worked fine. here example of barcharts androidplot.
, sum different values , (if want to) normalize it.


to display graphs, may create layout framelayout , this might working the z-order. thing have now, showing/hiding part of layout, containing graphs. (view.setvisibility)


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -