Color detection in a static image - OpenCV Android -
i have image 4 squares red, green, blue , yellow. need rgb values of each squares. i'm able rgb of whole image, want specific section.
- the image going camera , stored onto sdcard
i don't know if understand exactly, here comes.
you need create bufferedimage object rgb value:
file f = new file(yourfilepath); bufferedimage img = imageio.read(f); you can rgb color values image then. have 4 squares; check rgb values, can check corner pixels' rgb values:
color lefttop = new color(img.getrgb(0, 0)); color righttop = new color(img.getrgb(img.getwidth - 1, 0)); color leftbottom = new color(img.getrgb(0, img.getheight - 1)); color rightbottom = new color(img.getrgb(img.getwidth - 1, img.getheight - 1)); after it's easy red, green , blue values individually:
int red = lefttop.getred(); int green = lefttop.getgreen(); int blue = lefttop.getblue(); edit: i'm sorry, didn't see it's android. said, android doesn't have imageio class. accomplish task in android, first initialize image:
bitmap img = bitmapfactory.decodefile(yourfilepath); from operation pretty same:
int lefttop = img.getpixel(0, 0); ... int red = color.red(pixel); int blue = color.blue(pixel); int green = color.green(pixel);
Comments
Post a Comment