Skip to main content

[JAI] Image pattern comparison

3 replies [Last post]
Anonymous

Hello all,

I have an 80x80 B&W template image and a bunch of B&W 80x80 images.

I would like to know how to use JAI (or any Java API) to compare the closest match based on patterns. Basically I would like to know which image resembles the template image the most.

Thank you for any assistance you can provide.

Jean
---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Tara Gilliam

Hi Jean,

I was trying something similar a while back with JAI. The two similarity
measures I was interested in were a pixelwise correlation (i.e. overlay the
images and count the number of matches) and cross-correlation (effectively
trying the previous tactic at all possible offsets, and picking the best match).

Cross-correlation was the best option for me, I don't know what would be best
for your application though.

C-C can be very time consuming and so is usually implemented using Fourier
transforms - unfortunately I had no luck getting this working with JAI. It seems
to have been tried several times before too, but if you want to have a go the
following may be helpful:
http://en.wikipedia.org/wiki/Cross-correlation
http://markmail.org/search/?q=jai+cross-correlation

(I eventually moved to Matlab for this, as it has a built-in xcorr2() function.
I believe someone has implemented this for Octave as well (although I haven't
tried it) if you'd like to go that route.)

Pixelwise correlation is much easier and only really requires access to the
individual pixel values, e.g. BufferedImage.getRGB(). There's probably a better
way of doing it than checking all pixels in a loop, but I haven't really looked
into it.

Do post back to the list if you have particular implementation questions!

Hope that's of some use,
Tara

Jean Vence wrote:
> Hello all,
>
> I have an 80x80 B&W template image and a bunch of B&W 80x80 images.
>
> I would like to know how to use JAI (or any Java API) to compare the closest match based on patterns. Basically I would like to know which image resembles the template image the most.
>
> Thank you for any assistance you can provide.
>
> Jean
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Rafael Santos

Jean,

> I have an 80x80 B&W template image and a bunch of B&W 80x80 images.
>
> I would like to know how to use JAI (or any Java API) to compare the closest match based on patterns. Basically I would like to know which image resembles the template image the most.
>
Your basic problem is to define "resemble". Imagine a way to assign
numbers to the images based on their contents, so we could consider that
images with closer numbers would be closer in contents. In practice we
should use vectors of numbers who reflect characteristics on the images;
the closest the vectors, the closest the images. There is a whole world
of techniques to do that, but the real trick is to extract numeric
features from the images that can be used in those comparisons.

There is a crude example on
http://www.lac.inpe.br/JIPCookbook/6050-howto-compareimages.jsp that may
help you.

For BW images of fixed size it may be easier, but it depends on the
nature of the image and on some constraints. Do you have some examples
of "similar" and "dissimilar" images?

> Thank you for any assistance you can provide.
>
> Jean
>

I really appreciate when people explain their problems clearly and sign
their messages, and am frustrated by the people who just send their
assignments without context or information and (of course) without
identifying themselves. But then I am old and used to the old ways :-)
Now get off my lawn.

Rafael

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

irkhamov
Offline
Joined: 2013-07-16

Sorry Rafael and so Jean for interrupting :)

I've searche thru g**gle and find this question about comparing images by pattern matching.
I'm working on problem similar to Jean, trying to translate image of braille text to alphabet.
I have image(s) containing dots represent braille text. I've sharpened and then do edge detection to that image resulting in BW image containing only dots.
My problems are :
1. how to consider square area which will be region of interest that will match/cover exactly 1 braille character from that image
2. if I have found proper ROI, then how to compare that ROI to predefined image(s) that considered to be dictionary for converting braille to text. I guess pattern matching is fit to my problem than masking ROI to dictionary for example. But I really don't know how to pattern matching that ROI to patterns predefined on dictionary image.

I hope someone will enlight my problems above. Thanks b4, Rafael