How to check if an image is contained in another image? - java

I am trying to check if an image is on a program's interface. I know how to grab the program's image but I cannot figure out a way to check if the image on on the program's screen. How can I do this?

I think checking containing one image in another is a question of "computer vision", so maybe some special libraries like OpenCV can helps you.
And this question on stackoverflow could be so useful too
OpenCV Template Matching example in Android

If you want to do the checking within the same program as the one that loads the image, it should be possible by checking the user interface control properties/attributes, and also the return values of the functions/methods used to set the image. In such a situation, Computer Vision is overkill. In this case, may be you can post some of the code used for loading the image, so that others can suggest solutions.
But if you are using a different program to capture the screen and look for the image, SIFT and SURF features of OpenCV should do the job. The accuracy won't be bad in this application.

Related

How to program a GIF using any type of image/ object with processing?

I have used Java language for beginners is used with object type calling so there's an app or software called processing that I used that's a bit easy at making programs... (https://processing.org/)
What could be the best shortest example to make a animated GIF using shapes/ images?
What way could be the best way to make a GIF animated in regular Java without using processing software?
What could be the easiest examples for a beginner to do an animated GIF?
Stack Overflow isn't really designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense:
You need to break your problem down into smaller steps and then take those steps on one at a time. Can you create a simple animation? Something simple like a circle moving around the screen. Separately from that, can you export a single .png image from a sketch? Again, just something simple. Work your way forward in small steps: can you then export each frame of a simple animation as a .png file?
Then when you have those .png files, you can use something like Image Magick to convert them into an animated gif file.
The Processing reference is your best friend for questions like this. The save() and saveFrame() functions could come in handy for exporting an animation as a gif.
Please try something, and if you get stuck, post a MCVE along with a more specific technical question in a new post. Good luck.

Convert image to sketch and then cartoonify?

My aim is to let the user take a selfie from my app and then apply different image processing algorithms to convert it in a cartoon type image. I followed the algo written here, and then also used the method written just below the chosen answer to convert black and white sketch to colored image that should look like cartoon. Every thing is ok except that after applying Gaussian Blur , the image becomes too hazy and unclear. Here is the image output:
Any advice how I can make it more clear? Like shown in this link. I know they used Photoshop , but I want to achieve it with Java and Android.
PS: I found all the image processing methods from here. Plus the method mentioned here (the one below the chosen answer), what could be the ideal values in the arguments?
cartoonifying image
If you have a basic knowledge of C++, you can port this app for your need.
This application works real time. If you want to non-real time,than you can use bilateral filter against two medianBlurs at the bottom of function. That will give better results, but bad performance. But you need to use OpenCV in your application. If you want to make application with more functions, I will suggest you to do it.

How to detect if the image contains the given object or area or these two images are the same in OpenCV

I want to check if the image contains the given part (a small image in side it) or these two image are the same.
For better understanding my question look to image bellow.
The image which I am looking for inside another images:
Some other images:
These images are not the same size. As we look to images above the first, third and forth images containing the given image.
So I have tried three ways to do this:
1. The first way is using OpenCV norm function which is in OpenCV Core class.
2. The second way is comparing histograms of images.
3. The third way is using the algorithm FAST and ORB.
But no one was worked better for me, the first way was working when two images are very the same to each other. The second way was working when two images are almost the same. The third way also was working when the part of images are very the same.
So I cannot get good result using above ways.
If anyone can tell how to do this.
Note: I am using OpenCV 3 in Java, SURF and SIFT not supported.
Thanks in advance!

How to improve the image quality before the image processing start in javacv or opencv?

I have an image with 400x400 image to identify different components from it. But when I try to identify components using that most of time it doesn't provide correct answers. So I need to know whether there are some kind of methods in javacv or opencv to improve the quality of the image or increase the size of the image without effecting to its quality ?
This is the sample image that I use. (This is the maximum size that I can get and I can't use any photo editing softwares in the project, because it's dynamically generated image.)
In my image processing I need to identify squares and rectangles that connects those squares. And specially I need to get the width and height of those using pixel values.
You can scale it to any size, if you can vectorize it... and in your case vestorization is quite simple as you have some simple geometrical objects in image.
So, in my view your approach should be like this:
detect edges in the image with a high threshold (as you have very distinct objects)
vectorize them
scale them to any size
You should also look at the following link: Increasing camera capture resolution in OpenCV.
If you stick to image processing the easiest way to do it is to apply an equalizeHist(). This will increase contrast and will improve subsequent steps.
But, and this is a biiiig 'but', why are you doing it? Just reading this post, I saw another solution, and a quick google proved me I am right:
Kabeja is a Java library for parsing, processing and converting
Autodesk's DXF format. You can use Kabeja from the CommandLine or
embed into your application. All parsed data are accessible with the
DOM-like API.
That means you can extract directly all the data you want from that image in a text format. Probably something like "at position x, y there is a transistor, or whatever." So why would you render that file into an image, then analyse that image to extract the components?
If you do it for school (I know that many school projects are like this) I would recommend you to find a real problem to solve, and propose it to your teacher. You will be happier to do something that is not complete nonsense.
vectorizing the image is best option I guess as suggested by mocap.
you can also use enhancement tools like sharpening, saturating etc.

How do I use Java to search an image for a specific image/logo/sign, etc?

I'm creating a small game for my uncle (who's running for some political office), a "Find the Sign" game, where users are presented an image, and they search and click on the sign in the picture. Like, the user is shown a picture of a building, like a store or something, and they need to click on the campaign sign that's been posted in the window. There are different kinds of signs, but they all have the same logo in common.
If you truly want to go down the path of image recognition there are well known algorithms.. try Googling around for some, but a few you could look at are SIFT of SURF for instance. Getting something working might take quite an effort though - maybe you could look for a library implementation.
However in your case it seems like that's a bit overkill. If it's a small game as you say, I'm guessing you will be presenting a not too large number of images. You can just annotate each image with the coordinates of the logo you're looking for, say with a simple rectangle, and check if the user clicked within that pre-determined region. This is a small manual overhead for each image - probably not much larger than what you would already do manually to package each into your application/database.
For example, a simple hard coded map might do. You can probably think of a better approach.
Map<String,Rectangle> mapLogoLocationToImage = new HashMap<String,Rectangle>();
mapLogoLocationToImage.put("post_office.png",new Rectangle(1,1,5,5);
mapLogoLocationToImage.put("office_block.png",new Rectangle(3,7,4,6);
.
.

Categories