I am fairly new to game development.

I am developing an application(Aquarium) for windows which requires me to animate(move) fishes around the screen and user will be able to add new fishes drawn on paper and scanned into the application, I did some research and decided to use LibGDX so when user scans the image coming to the system has White background which needs to be removed I needed to know how to remove that make it transparent in LibGDX.

  • 1
    \$\begingroup\$ why not write a custom shader which renders colors above some threshold as transparent? \$\endgroup\$ – Benedikt S. Vogler Aug 29 '16 at 14:44

It seems like you are asking more about image processing and not LibGDX specifically. Once you change the white background to transparent pixels, then LibGDX will draw it without the transparent pixels.

The algorithm that you are looking for is called Background subtraction or Foreground detection. I have had some success before (albeit in Android) with OpenCV and I believe that you should be able to get the library working on Desktop within Libgdx. It is open source and free to use commercially.

OpenCV has a Java interface and it has a function called grabcut() that does Background subtraction. It is a bit more accurate if you have your user give hints for which pixels are foreground.

Here is another SO post that may help you get OpenCV working

  • \$\begingroup\$ i have worked with image processing in matlab and opencv i want to achieve the same in Libgdx \$\endgroup\$ – Lokanath May 24 '16 at 10:24
  • \$\begingroup\$ Perhaps you could clarify your question then. What part about using these algorithms in libgdx do you need help with? It should be as simple as linking to the libraries and then using them since Libgdx uses java. \$\endgroup\$ – spectacularbob May 24 '16 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.