0

I have the following image:http://www.salesreceiptstore.com/fake_receipt_templates/make-a-fake-restaurant-receipt-Large.JPG Basically a Receipt with data on it...

How can I automatically remove the background. I need this in order to make the OCR step faster.

user3128955
  • 103
  • 1
  • 1
  • 6

1 Answers1

0

I think you can make make use of Xamarin CropImage Library which is directly ported from a Java CropImage Library.

Refer :


You can also try something like this

    ImageView imgView;
    int PicCrop = 1;

-

    private void PerformCorp (Uri picUri)
    {
        try
        {
            Intent cropIntent = new Intent("com.android.camera.action.CROP");
            // indicate image type and Uri
            cropIntent.SetDataAndType(picUri, "image/*");
            // set crop properties
            cropIntent.PutExtra("crop", "true");
            // indicate aspect of desired crop
            cropIntent.PutExtra("aspectX", 1);
            cropIntent.PutExtra("aspectY", 1);
            // indicate output X and Y
            cropIntent.PutExtra("outputX", 128);
            cropIntent.PutExtra("outputY", 128);
            // retrieve data on return
            cropIntent.PutExtra("return-data", true);
            // start the activity - we handle returning in onActivityResult
            StartActivityForResult(cropIntent,PicCrop);
        }
        // respond to users whose devices do not support the crop action
        catch (ActivityNotFoundException ex)
        {
            // display an error message
            Toast.MakeText(this, "Whoops - your device doesn't support the crop action!",ToastLength.Short).Show();
        }
    }

-

    protected override void OnActivityResult(int requestCode, int resultCode, Intent data)
        //:base.OnActivityResult(requestCode,resultCode,data)
    {
        if (requestCode == PicCrop) {
            if (data != null) {
                // get the returned data
                Bundle extras = data.Extras;
                // get the cropped bitmap
                Android.Graphics.Bitmap selectedBitmap = extras.GetParcelable("data");

                imgView.SetImageBitmap(selectedBitmap);
            }
        }
    }

Refer : https://stackoverflow.com/a/15239086/3891036

Community
  • 1
  • 1
Yksh
  • 3,276
  • 10
  • 56
  • 101
  • Thanks for the info, but do you know any way of automatically getting only the part that i need as i don`t want any user input other than taking the image... – user3128955 Jan 22 '16 at 07:11