Image processing, replace picture background or cut out picture background - android

In an Android app, I would like that the user choose or take a picture of him from / with his device and then replace the background by another one (for example an awesome beach).
I'm looking for a library that can cut out the original picture background (the original background can be a color or maybe a landscape). Or maybe a library that can give me some tools to draw the part of the picture to keep / remove.
If a such library does not exist, I think that the "pixel replacement" method is the best way if the original picture has a color background (for example, I look for all the black pixel and change them with a transparent pixel).
I have found this tutorial but as you can see the result is not perfect. Is there a way to do not check only one color but a range of colors ? Is there a way to define programmatically the range of colors to check ?
Thank you in advance for your tips and links !

Related

Changing drawable Image colors to a specific color?

I am new to tesseract.
The image provided is just an example, the actual image is an Identity Card.
I have a question. I would like to change the background colors to a specific color. Let's say 'black' but the text color remains the same. Is it even possible? I am not sure what exactly I am supposed to be learning in order to achieve it.
The purpose of converting the image color is because when I run my tesseract on my ID, It displays some weird symbols. This is because the ID consists of background designs. Any guides will really be helpful ! Thank you !
UPDATE
Okay, I found this image from google search.
This will be the image that I will be loading into my application under ImageView. Is there any way that I can only keep the black text on the Identity Card and remove every other colors from the image to white, pixel by pixel? Can it be done ?
*Sorry for not providing a proper explanation previously! *
RelativeLayout background;
background = (RelativeLayout) findViewById(R.id.background);
background.setBackgroundColor(
ContextCompat.getColor(MainActivity.this,R.color.black));

Android Bitmap - Replace an object's color keeping Anti-Aliasing

I have an image in my assets folder on which I am drawing stuff using an external program and then using them in my app. The problem is that the bitmaps are blank (transparent) with black and white objects in them. Note that the objects are created with Anti-Aliasing on to look better. I know this was asked before but I couldn't find what I want. I need to replace all the black and white pixels in the image (even the transparent anti-aliased ones!) to the colors given by the user. Below are some images to show what I want to do:
Please note that this is just an example and I have even some very complicated shapes and the final colors aren't known (as inputed by the user in RGB style).
Any help is appreciated. Thanks! :)
Usually you can tint the images you load apliying them a color at runtime.
The problem is that color applies to the whole image and it only matchs exactly the same color in white pixels, with or without alpha.
So you could separate all the areas of the image with the same color, save them as white and then tint them at runtime while overlapping one over another.
It depends on the framework you are using.

How can I get rid of transparent background space in (Android Asset Studio - Icon Generator)?

When I upload my image (which has no background to begin with), it is automatically given transparent background no matter what settings I choose. I really like the "Square" shape (rounded corners) but there is way too much excess transparent background. When I see the icon on my phone it looks so small compared to Facebook for example. How can I get rid of this extra background space to make it as large as possible? Is one of my settings off?
http://reiszecke.github.io/AndroidAssetStudioFullsize/
Just click on >> Launcher icons << Full Size edit
pls mark as answer if it helped.
EDIT: only works on "bevel" and "none", I will adjust the other shapes at some point
http://www.gieson.com/Library/projects/utilities/icon_slayer/
Does the job but the an image must be provided first.
Creating the logo and background with LIG and loading the result in the gieson's icon_slayer should do it.

Android 9-patch image usage

OK, I've read a lot of tutorials and even downloaded some examples, but for the love of Stackoverflow, I can't get my image to stretch like I want it to and I'm hoping that someone can help me out here.
I create an image that is to be the background of a button object in Android. Here is the image:
Now, I'd like for it to stretch to the desire size of the button, whether the button is 50x50dp or 200x100dp. One thing I don't want is the border to stretch as it will look distorted, so I want to specify not to include the border, but stretch everything else to the desired size of the button.
Can someone please show me where the black lines need to go in order to achieve my goal? Do I have to change my original image in order to achieve my goal?
Thank you in advanced.
David
It's very simple using this tool Android Asset Studio: Simple 9-Path Generator. Although no matter how you do it you will have stretching and distortion due to the textured (non-patterned) background. I would stay away from that style both personally and for usability.

Change the Layout Background using image color code in Android

I am using the viewPager for Gallery and used "Depth Page Transformation" for animation i need to set the background according to the image. The background color should match with the image color meaning it should pick the background color from the image. Does any one know this..please tell me.
Loop through all the pixel's color data and average the color values, ignore anything that is a shade of grey or transparent. I believe that is what Microsoft does in Windows 7 based on a recent blog post.
See this blog post: http://blogs.msdn.com/b/oldnewthing/archive/2011/12/06/10244432.aspx
This link showing how Chrome picks the dominant color may also be helpful. http://www.quora.com/Google-Chrome/How-does-Chrome-pick-the-color-for-the-stripes-on-the-Most-visited-page-thumbnails
Find this snippet for android
http://forums.makingmoneywithandroid.com/android-development/406-%5Bhow-%5D-get-average-color-drawable-bitmap.html

Categories

Resources