title: Simple Image Correction for Older Android Cameras
body: <p>I have an android application where I am trying to let the user capture an image of a document with the native camera and then send it to the server to be made black and white.</p>
  
  <p>In the android app I'm following <a href="https://developer.android.com/training/camera/photobasics.html" rel="nofollow noreferrer">this example</a> to capture a full size photo from the camera.</p>
  
  <p>The issue I'm having is that an old Nexus 4 camera results in a darker image, and therefore parts of the document are made black instead of white (mostly around the edges of the document). But with a newer Nexus 6 camera there is no issue.</p>
  
  <p>Using <a href="https://stackoverflow.com/a/17887577/1088659">this code</a> to change the contrast/brightness works great for increasing the quality of the the Nexus 4 image, but washes out the newer Nexus 6 image.</p>
  
  <p>Is there a way to automatically detect a darker, poor quality image from an older android device in order to apply the image correction only to those images?</p>
  
  <p>Simply calculating the average brightness of the image with <a href="https://github.com/damson/Bright/blob/master/library/src/main/java/com/devddagnet/bright/lib/Bright.java" rel="nofollow noreferrer">this code</a> is thrown off by the possibility of a dark background surrounding a document.</p>