The image below is taken from Officelens as they convert the bit-depth of the image the make a clear Black&white image which is on the top and original image on bottom:
But when I try to convert I am getting the output given below:
the above result is done using tif convertion library my tried code is given below;
private void takePicture() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File folderPath = new File(Environment.getExternalStorageDirectory() + "/OCR");
if (!folderPath.exists()) {
if (folderPath.mkdir()) ; //directory is created;
} else {
File photo = new File(folderPath, "OCRPIC" + UUID.randomUUID().toString().substring(0, 5) + ".jpg");
imageUri = FileProvider.getUriForFile(MainActivity.this,
BuildConfig.APPLICATION_ID + ".provider", photo);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, PHOTO_REQUEST);
}
}
As I save image from camera to internal storage and on while retrieve I will convert for color compression, code given below,
TiffConverter.ConverterOptions options = new TiffConverter.ConverterOptions();
options.throwExceptions = false;
options.availableMemory = 1 * 1024 * 1024;
options.compressionScheme = CompressionScheme.LZW;
options.readTiffDirectory = 1;
TiffConverter.convertToTiff(path, Environment.getExternalStorageDirectory() + "/OCR"+"/"+path.substring(path.lastIndexOf("/")+1).substring(0,11)+".jpg", options,null);
I want to achieve the ouput that produced by Office Lens.