Reputation: 395
We are developing an app where we need to crop an image according to the selecting object area. User will draw a line and we need to select the object and crop it .This crop need to be like the app: YourMoji
So far we have tried to get the color of the pixels along the line and then comparing those with the color of every pixel in the image and making a path from it to clip the image. But the almost going no where.
Is it possible through this way to crop an image or we are going in the wrong way? Can anyone provide a way to do this Or suggest a way to modify the way we have worked so far?
Any advice and suggestions will be greatly appreciated!
Thanks in advance.
Upvotes: 1
Views: 188
Reputation: 46
I guess what you want is the image segmentation algorithm called Graph Cut.
Here are two Github repositories, hope these would help:
Upvotes: 1
Reputation: 32066
I'm not exactly clued up on image manipulation, but the first algorithm that comes to mind is something like this:
For each pixel, if the colour is within a given threshold outside of your selected average, remove it / make transparent.
Perhaps the closer to the original line (or centroid), the less strict the threshold becomes.
I'd then provide the user with some tools for:
Upvotes: 1