find sub-images within an image - java

I want an efficient way to finding out sub-images from a Image for Ex. we have a image of country map and it contain states as sub-image.
Then i need a way to finding out sub-images of states from country map.

If you have only pixels, you'll need image processing algorithms to find sub-images.
Your solution will be specific to what the image you are processing looks like. For example, if states are outlined in a certain color, you could try edge detection. If states are each different colors, you could run a flood fill like algorithm to create boundaries for each state.
This is a difficult problem. Try computer vision or object recognition for keywords in your research.
However, I suggest instead you build up vector files which define boundaries of subimages by hand. If you've only a few to do, this isn't a big deal.

Related

Using Java & BoofCV to detect shapes in an image file

I've not found anything here or on google. I'm looking for a way to identify shapes (circle, square, triangle and various other shapes) from a image file. Some examples:
You get the general idea. Not sure if BoofCV is the best choice here but it looks like it should be straightforward enough to use, but again I know nothing about it. I've looked at some of the examples and I though before I get in over my head (which is not hard to do some days), I thought I would ask if there is any info out there.
I'm taking a class on Knowledge Based AI solving Ravens Progressive Matrix problems and the final assignment will use strictly visual based images instead of the text files with attributes. We are not being graded on the visual since we only have a few weeks to work on this section of the project and we are encouraged to share this information. SOF has always been my go to source for information and I'm hoping someone out there might have some ideas on where to start with this...
Essentially what I want to do is detect the shapes (?? convert them into 2D geometry) and then make some assumptions about attributes such as size, fill, placement etc, create a text file with these attributes and then using that, send it through my existing code based that I wrote for my other projects to solve the problems.
Any suggestions????
There are a lot of ways you can do it. One way is to find the contour of the shape then fit a polygon to it or a oval. If you git a polygon to it and there are 4 sides with almost equal length then its a square. The contour can be found with binary blobs (my recommendation for the above images) or canny edge.
http://boofcv.org/index.php?title=Example_Fit_Polygon
http://boofcv.org/index.php?title=Example_Fit_Ellipse

how to get a region out of an image?

Lets say I use a black key jpg image as my layout in Java Code. Is there an easy way to get the region out of an image so I can use region.Contains() for my onTouchListener?
I've looked for them and there isn't any. I ask this because Im making a piano app and would like to get the regions of the images I use for the black/white keys.
Rather than use an image, try rendering the piano keys yourself, and check if input is in the black key regions you render, rather than using an image.
If you really want to use the image, define the black regions within the image by hand.
Detecting regions in an image is a difficult problem, one you probably don't want to get into for such a simple purpose. If you had many images, or had to do this frequently it might be worth the headache but as you presumably don't... don't worry about it.

find perceptual similarity between two images in java

I'm looking for an algorithm that can find perceptual similarity between two images, actually i want to input one picture into system and it search whole my database which contain huge amount of picture and then retrieve the images which have more perceptual similarity with source image, could any body please help me ?
I mean i want to find similar pic. i heard some algorithm can find similar pictures base on the source pic's shape, color and etc (pixel by pixel). i wanna have the system that i input the source image and system retrieve the similar images based on perceptual features like shape, color, size and etc.
Thanks
You need to define carefully what 'perceptually similar' means to you, before trying to find a measurable entity that captures that. Imagine a picture of of a grass field under a blue sky with a horse. Should your application retrieve all horse pictures? Or all pictures with green grass and a blue sky? In the latter case, the above mentioned color histograms are a good start. Alternatively you could look at gaussian mixture models (GMM), they are used quite a bit in retrieval. This code could be a starting point and this article Image retrieval using color histograms
generated by Gauss mixture vector quantization
More complicated is the so called "bag of words" or "visual words" approach. It is increasingly used for image categorization and identification. This algorithm usually starts by detecting robust points in an image, meaning that these points will survive certain image distortions. Example popular algorithms are SIFT and SURF. The region around these found points is captured with a descriptor, which could for example be a smart histogram.
In the most simple form, one can collect all data from all descriptors from all images and cluster them, for example using k-means. Every original image then has descriptors that contribute to a number of clusters. The centroids of these clusters, i.e. the visual words, can be used as a new descriptor for the image. The VLfeat website contains a nice demo of this approach, classifying the caltech 101 dataset. Also noteworthy, are results and software from Caltech itself.
One simple way to start is comparing the Color Histogram.
But the following article proposes the use of Joint Histogram instead. You may also take a look.
http://www.cs.cornell.edu/rdz/joint-histograms.html

Java detection of images on a screen

I'm trying to take an ongoing chess game and use image recognition to automatically transcribe it into a list of chess moves (1. e4 e5 2. Nf3 Nc6), automatically.
Given a 2D layout of the board and pieces, and standard images for each of the pieces, how would I go about in Java doing this?
Thanks!
I would imagine that depending on the set being played with, given a top down view of the board, it might prove difficult to distinguish between the different pieces.
Rather than relying on image recognition to determine which pieces are which, it would almost certainly be easier to simply track the pieces throughout the course of the game. You already know exactly where they started from, so after each turn it should be possible to deduce which square is now empty that wasn't previously empty, and which square is now occupied that wasn't previously occupied. This makes your image analysis much simpler as you're just determining whether each square on the board is empty or not.
Well if you have an image for each piece than just follow and save(using some arrays) all the moves. But first show us some code on what you have. More info.
For image classification in JAVA you can try Rapidminer and IMMI extension for image mining:
http://spl.utko.feec.vutbr.cz/en/component/content/article/46-image-processing-extension-for-rapidminer-5
For this purpose you should extract global features from images and than train some classifier (e.g. SVM). Another approach might be training Viola-Jones detector.

Find an Image within an Image

I am looking for the best way to detect an image within another image. I have a small image and would like to find the location that it appears within a larger image - which will actually be screen captures. Conceptually, it is like a 'Where's Waldo?' sort of search in the larger image.
Are there any efficient/quick ways to accomplish this? Speed is more important than memory.
Edit:
The 'inner' image may not always have the same scale but will have the same rotation.
It is not safe to assume that the image will be perfectly contained within the other, pixel for pixel.
Wikipedia has an article on Template Matching, with sample code.
(While that page doesn't handle changed scales, it has links to other styles of matching, for example Scale invariant feature transform)
If rotation also had to be catered for, the Generalised Hough Transform can be used.
You can treat this as a substring problem, where characters in the alphabet are pixels and your string is the image. You would need also to use a special character in a similar vein to a linebreak, to denote the image boundary.
The algorithm you want is on wikipedia: http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
Update: If you cannot assume that the image is perfectly contained within the other, pixel for pixel, then this approach will not work.
There are other, more complicated algorithms based on the same dynamic programming concept as the above, but I won't go into them unless it's necessary.

Categories

Resources