As I'm sure you know, taking a picture of a white paper won't fill every pixel with 0xFF (assuming 256 colors), but it will fill most bytes with a high number. So you could take a sample, like 10 or 100 pixels evenly distributed around the image, and do some lightweight statistical analysis on the samples. For example, toss out the lowest 10%, and average the rest. If it's above, say, 0xDD then it's a white paper.
Yusuf Saib Android ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Jul 21, 1:08 am, Piwai <[email protected]> wrote: > To me, it seems that making computations pixel by pixel is the only > solution... > > However, there might be a faster solution than using getPixels : using > a buffer. See copyPixelsToBuffer method in the Bitmap class. A buffer > is read only or write only, and I guess it might use lower level > computations and run faster (but you should test this, because its > just a guess from me). getPixels, getPixel, and copyPixelsToBuffer are > all calling native (C++ ?) methods in the bitmap class, so it's quite > hard to guess which one is faster from just reading the java code. > > By the way, once you have the process to read the pixels, it won't be > so easy to determine if a photo is white.. Because I guess it will > never be "plain white", more like "whie grey" with noise etc... But > there should exist some algorithms that will do the job. > > Good luck! > > On Jul 21, 7:38 am, alucard20004 <[email protected]> wrote: > > > > > (please forgive my imperfect English.) > > > Hi. I'll get straight to the point. > > > Please note that I haven't code anything in this project just yet. > > This is only an idea. > > > In human language, my goal is to: > > > 1. Take a picture of a blank white A4 paper. > > 2. Verify (by code) that the picture is "White". (this's why I include > > 'simple' in the topic) > > > I mean, the program should be able to tell if the user just took the > > picture of "white" paper and not any other colors. > > > For the code... > > I can guess that the actual process should be: > > > 1. Use Camera API to take a picture. // this step should be easy > > 2. Convert it to Bitmap. // this step should also be easy > > 3. Verify that it is "White". //*** now I need some help here. > > > How can I do step 3? I look up the docs and found this is the Bitmap > > class: > > > getPixels (int[] pixels, int offset, int stride, int x, int y, int > > width, int height) > > > I can use this and compare the data pixel-by-pixel but it seems > > expensive. > > > Could anyone recommend me a more proper way(if there is) to do this > > please? > > > Thank you in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

