Android Question Auto cropping image

Matteo Granatiero

Active Member
Licensed User
I would like to automatically crop an image by removing the background like this:
 

Attachments

  • 54224BC9-6F43-45DB-A6E3-0BACDA781F5E.jpeg
    31.9 KB · Views: 181

Sandman

Expert
Licensed User
Longtime User
I think it needs AI or some kind of algorithm to achieve it.
My first thought: LOL

My second thought: Oh, @aeric might mean actually removing background like this:


My interpretation of the non-question was this:

Meaning, removing background by cropping using a bounding box. (Shown as red outline here.)

We'll see if @Matteo Granatiero adds some background (pun intended) and perhaps even a question.
 
Upvote 0

Matteo Granatiero

Active Member
Licensed User
yes this is my question, sorry if I haven't been clear and specific ahaha
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
So, to be clear, you're looking to do this: Automatically crop an image to the bounding box?


It seems to be a quite simple problem to solve, what have you tried and what are your questions?
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
This sounds like it could be a job for OpenCV.

There have been a few ports to OpenCV for B4A over the years. There may be a function that allows you to isolate an object within an image – I'm not sure.

As someone else posted, this seems straightforward but it is an incredibly difficult problem.

Barry.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
but this is only to eliminate the transparent background, but in case of NOT transparent background?
This is only for transparent background, that's why I wrote that it is only "a bit related".
BTW, the image from the first question can be handled with a similar code. As already written several times there is a huge difference between removing a solid color background and removing real world background. These are completely different tasks.
 
Last edited:
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…