Extract parts of an image based on a raster mask?
Hi,
First of all I would like to say hi to the community because I'm a newcomer.
I have been reading about openCV for some days and I would like to use it in my jigsaw game (Android and IOS). What I need is to extract parts of an image based on pieces defined in another image (raster mask). The mask could be something like this:
This image is defining just the outlines of each piece at each position. And I would like to cut the image based o this outlines. Can OpenCV help with this? I'm a bit lost right now. My intuition is saying openCV can do this but don't know how to achieve it.
Any help will be greatly appreciated.
Cheers.
I understand your problem as your result will be 35 images? May be you can fill each mask with an index from 0 to 34
sure it is possible. like said above you will need 1 mask per piece type ( i can count only 21 uniques :) also those masks will need a border in the size of your nook, and you can just floodfill that border (even manually in paint or such)
but again, if you only need basic image processing, opencv might be far too heavy for you. (your clients will also need the opencv manager app from play store, which delivers the correct native c++ so's for your hardware)
Thaks for yor answers. The main reason to use OpenCV was to achieve a GPU solution. I think my software algoritm could work like this: 1) For all pixels do 2) Go to next pixel and check if transparency==255 or it was used in a previuos flood fill opration 3) If previous is true, return to 1 because we don't want this pxel. If false run a flood fill operation on this pixel and create an sprite from it based on the original image. We must keep a buffer to flag if pixel was used in a flood fill operation previously. Perhaps it could be the same temp buffer where we loaded the raster mask image.
I think this would work but I guess that it would be too slow. This is why I'm looking for a GPU solution using OpenCV.
Cheers.
just saying, there's usually decent opengl support on android. might still be an alternative for the sprite composition / alph / blitting.
creating the masks is actually an offline job, you don't have to do that from your app.
yes, this is true. The problem is that I tend to dig on things that I don't know how to do. And I have seen this method (the raster image mask)on other games and would like to come up with something like it :). Sorry to be so picky.