Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect blobs and crop them into png files?

i've been working on a webapp. i got stuck here in a problematic issue. i'll try to explain what im trying to do. here you see first big image which has green shapes in it. what i want to do is to crop those shapes into different png files and make their background transparent like the example cropped images below the big one.

Main image the input

Cropped 1.

Cropped 2.

Cropped 3.

The first image will be uploaded by user and i want to crop into pieces like the example cropped images above.it can be done with GD library of php or by a server-side software written in python or c#. but i dunno what this operation called so i dunno what to google to find information. it is something to do with computer vision detecting blobs and cropping them into pieces etc. any keywords,links would be helpful.

thanks for helps

like image 562
Ahmet Yildirim Avatar asked Dec 22 '22 18:12

Ahmet Yildirim


1 Answers

A really easy way to do this is to use Flood Fill/Connected Component Labeling. Basically, this would just be using a greedy algorithm by grouping any pixels that were the same or similar in color.

This is definitely not the ideal way to detect blobs and is only going to be effective in limited situations. However, it is much easier to understand and code and might be sufficient for your purposes.

like image 77
Brian Avatar answered Jan 01 '23 16:01

Brian