0

I have searched the internet thoroughly but couldn't find a solution

Here what i want

This is my image

enter image description here

This is how it looks with 0 transparency when i have selected

enter image description here

So programmatically i want to split image into 6 pieces. Each one containing one of the egg with 0 transparent area left

How can i do that?

My preferred solutions based on c# or photoshop script but i am open to all solutions

An example output

enter image description here enter image description here

Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
  • how do you replace the transparent area if you want 0 of it? background colour? – Piglet Apr 05 '19 at 09:11
  • @Piglet no just remove it. the result will be only egg with no transparent area. i mean extra area. i have updated the question – Furkan Gözükara Apr 05 '19 at 09:24
  • I ask myself if this is something you could just do in Photoshop or if the quantitiy is too high aks the source of those images to provide them as you need them... but if you insist on doing this automatically you should specify if you know the arrangement and size of eggs or if this may change. This would affect the choice of method to solve this – Piglet Apr 05 '19 at 09:28
  • Find a solution: https://stackoverflow.com/questions/33636849/imagemagick-split-image-by-background-color – shingo Apr 05 '19 at 09:35
  • @Piglet i have to do it programmatically. also i am sure a solution can be found without depending on the size of the image or the shape of the image. i think i can code a solution for this however i do not have time for that if an already solution exists – Furkan Gözükara Apr 05 '19 at 09:42
  • @shingo thanks i have checked but my images are not structured like that one – Furkan Gözükara Apr 05 '19 at 09:43
  • of course there are solutions that do it for any size and arrangement. but if position and size of the eggs were always the same you would pick another tool than if they were different. – Piglet Apr 05 '19 at 09:50
  • What you're looking for is Axis-Aligned Bounding Boxes, or AABBs. This should help you get a start on developing something there. – Vogel612 Apr 05 '19 at 10:31

1 Answers1

1

To solve this problem for any image size, egg size, orientation, position, count I suggest to use the following approach:

Load the image file.

Extract the alpha channel (this contains the transparency information)

find the egg blobs (blob search/analysis, region labelling, connected components, countless names for this method)

get the bounding boxes of those blobs

crop the sub images using those bounding boxes

This can be achieved with most image processing librarys. If you prefer C#, give EmguCV a try. Or use websearch to find others.

http://www.emgu.com/wiki/files/3.1.0/document/html/e13fa7a9-5eee-b46c-4b65-ff3e7e427719.htm

Piglet
  • 27,501
  • 3
  • 20
  • 43
  • thanks for direction i have solved the problem with this. took less than 30 minutes to code > http://www.aforgenet.com/framework/features/blobs_processing.html – Furkan Gözükara Apr 05 '19 at 11:22