Library to identifying the similarity between 2 image in android - android

Suggestions on the best (preferably easiest way) to compare two images in android.
The first image is in my SD Card.
The second image was taken using Camera in android.
How to measure percentage similarity between those 2 images??
Thanks a lot.

Android does not provide any picture comparison algorithms for you.
Therefore, you will need to write one yourself - one that fits your needs, since not all image comparison algorithms/techniques are the same, and some work better in some cases than others.
You might want to start by looking at the SIFT technique, and find an image matching algorithm that suits your requirements.

Related

How to use an asset in Android Ui?

I am new to Android Studio. While working on front end its sometimes easy to take some parts as png file and place it on the particular position instead of recreating it in xml file. I am confused can we use png all the time ? I am worried about memory space . Like the app contains 50 pages and in each page I use 1-2 assets . I don't want my app to have more than 40mb. What will be the best way to do? Can we store the image as a URL and retrieve it whenever we use. What's the drawback in that way?
So many questions :)
I am confused can we use png all the time ?
Use what's best for your picture. For a photo, a JPEG will probably do better. But if you wish, you can use PNG all the time, yes.
I don't want my app to have more than 40mb.
Check and see. Depends on how big your images are; we can't tell.
What will be the best way to do?
Not enough information to tell you that. In general, there's nothing wrong with using images in assets.
Can we store the image as a URL and retrieve it whenever we use.
Yes.
What's the drawback in that way?
You'll need to get some server space somewhere. Also, there will be a loading latency. Also, your app won't be usable while disconnected from the Internet.
While working on front end its sometimes easy to take some parts as png file and place it on the particular position instead of recreating it in xml file.
That's the part that is confusing to me. Android XML layouts usually contain interactive elements, ones that the user can interact with. Images, on the other hand, tend to be static. What kind of XML is there out there that you think you can replace by an image?

How to check if image exists in Gallery or not?

In my application when a user captures the image before saving into the gallery.
I want to check is there any image matches with the current image (at least 50%). If any image found get the image from gallery and display to the user.
I am very new to android development. Can anyone help me out to do above task.
You'll have to use a Java library for this. I suggest taking a look at this thread.
If you'd like to develop something on your own, the basic idea is this. To compare two images, represent each of them as a matrix of pixels and compute similarity between those two matrices. If you do choose to implement it yourself, take a look at matrix similarity, cosine similarity in particular. A very simple example is here.
Good luck!

Is it possible to verify the content of an image?

In what language(s) is it (if at all possible) to check the content of an image?
Ideally, I am looking for web / mobile languages, but whatever is possible.
As a comparative example, I wish to make the first image of a castle 'valid' and the second image of the wall 'invalid', due to there been no substantial content in the second image. Meaning, the second image, which is the wall, has too much similarity across the image and therefore doesn't contain valid content.
Please do not provide a 'how to do it', as I am a student and will be working out solutions for myself as much as possible, I just need to know that what I want to achieve is possible in the first place and a starting point for language(s).
**EDIT2: What Javier has suggested about computer vision is on the right track to what I mean. Image analysis to break it down a little more. I wish to visually analyse an image and determine how the range of varied the colours across an image are to determine if there is actually a proper image present on not just a picture of a wall

Which is a better way to extract grayscale pixel values in Android in terms of battery drain and processing time?

hope you are all well.
I am at a somewhat of a crossroads in my current project, I am needing to extract grayscale pixel values that will be sorted as per the discussion in my previous post (and very kindly and thoroughly answered).
The two main methods that I am aware of are:
Extract the grayscale from the Yuv preview.
Take the photo, and convert the RGB values to grayscale.
One of my main aims is simplicity, the project as a whole needs it, so thus my question - whaich of these two (or another method I am not aware of) would be the most reliable/stable, but would be less taxing on the battery and processing time?
Please note, I am not after any code samples, but are looking for what people may have experienced, may hve read (in articles etc) or have a intuitive hunch about.
Thank you for taking the time to read this.
I'm currently working on a project which also uses pixel values to do some calculations, and I noticed that it's better to use the values directly from the YUV preview if you only need the grayscale, or need to use the entire preview for your calculation.
If you want to use the RGB values, or only calculate something based on a certain part of the preview it's better to convert the area you need by converting to a Bitmap and using that for instance.
However, it all depends on what you're trying to achieve since no two projects are alike. If you have the time, why not (rougly) implement both methods and do a quick test to see what works better in terms of cpu usage and total processing time? That's how I found the best method for my particular problem.

Android efficient storage of two images which are similar

Application size on a phone needs to be as small as possible. If I have an image of a sword and then a very similar image of that same sword except that I've changed the color or added flames or changed the picture of the jewel or whatever, how do store things as efficiently as possible?
One possibility is to store the differences graphically. I'd store just the image differences and then combine the two images at runtime. I've already asked a question on the graphic design stackexchange site about how to do that.
Another possibility would be that there is that apk already does this or that there is already a file format or method people use to store similar images in android.
Any suggestions? Are there tools that I could use to take two pngs and generate a difference file or a file format for storing similar images or something?
I'd solve this problem at a higher level. For example, do the color change at run-time (maybe store the image with a very specific color like some ugly shade of green that you know is the color to be fixed at run-time with white or red or blue or whatever actual color you want). Then you could generate several image buffers at load-time.
For compositing the two images, just store the 'jewel' image separately, and draw it over the basic sword. Again, you could create a new image at load-time, or just do the overdraw at run-time.
This will help reduce your application's footprint on flash, but will not reduce the memory footprint when the app is active.
I believe your idea of storing the delta between 2 images to be quite good.
You would then compress the resulting delta file with a simple entropy coder, such as Huffman, and you are pretty likely to achieve a strong compression ratio if similarities with base image are important.
If the similarity are really very strong, you could even try a Range Coder, to achieve less-than-one-bit-per-pixel performance. The difference however might be noticeable only for larger images (i.e higher definition than a 12x12 sprite).
These ideas however will require you or someone to write for you such function's code. This should be quite straightforward.
An very easy approach to do this is to use an ImagePack ( one image containing many ) - so you can easy leverage the PNG or JPG compression algorithms for your purpose. You then split the images before drawing.

Categories

Resources