Skip to main content

Cross-correlating 2 images to find match

9 replies [Last post]
cozytrony
Offline
Joined: 2007-06-19
Points: 0

Hi guys,

i am in a blank now regarding problems with the cross-correlation function with JAI
i know to find cross-correlation coefficient of 2 images i have to perform
IDFT(DFT(baseImage),conjugate(DFT(matchTemplate)) to find a match

but the problem arise, i get back a RenderedOp Object, and i have no idea how to
derive a sensible value that i can relate to which a match has been found between the baseImage and matchTemplate.

Any kind soul out there that have any idea on how i can go about playing with the cross-correlated image??

I attempted to convert the RenderedOp image into a awt.Image object for display, and guess what i see a big patch of white rectangle at the top left corner of the entire image, with the rest populated by black background with "colored" strips in the foreground?

please explain to me this anyone? many thanks beforehand

Regards
Cozytrony

Reply viewing options

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

Hi guys,
My 2 cents.

I would recommend being careful when doing getData() with rendered images
since under some conditions it may trigger a copy of all the data of the
underlying image at once.
There are better method for accessing the backend raster depending on the
mage type (PlanarImage, TiledImage, BufferedImage, etc..) but if you want to
be general you should access the back end raster on a per-tile basis using
the getTile methods.

Ciao,
Simone.
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

-----Original Message-----
From: Fork Labs [mailto:forklabs@gmail.com]
Sent: martedì 19 giugno 2007 17.58
To: interest@jai.dev.java.net
Subject: Re: [JAI] Cross-correlating 2 images to find match

Hello cozytrony,

A RenderedOp is a RenderedImage, you can access its raster by using
method getData().

To be able to see the result of you DFT's, it is usually viewed after
a call to operator "periodicshift" (it will center the DFT).

Regards,

Daniel Léonard

---------------------------------------------------------------------
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

bpb
Offline
Joined: 2004-06-23
Points: 0

In general for JAI images if the region requested via getData() is contained within a single tile then a child Raster of that tile will be returned unless the image is writable in which case a copy will be returned. If the requested region overlaps more than one tile then data will always be copied.

> Hi guys,
> My 2 cents.
>
> I would recommend being careful when doing getData()
> with rendered images
> since under some conditions it may trigger a copy of
> all the data of the
> underlying image at once.
> There are better method for accessing the backend
> raster depending on the
> mage type (PlanarImage, TiledImage, BufferedImage,
> etc..) but if you want to
> be general you should access the back end raster on a
> per-tile basis using
> the getTile methods.
>
>
> Ciao,
> Simone.
> ------------------------------------------------------
> -
> Eng. Simone Giannecchini
> President /CEO GeoSolutions S.A.S.
> Via Carignoni 51
> 55041 Camaiore (LU)
> Italy
>
> phone: +39 0584983027
> fax: +39 0584983027
> mob: +39 333 8128928
>
>
> http://www.geo-solutions.it
>
> ------------------------------------------------------
> -
>
>
> -----Original Message-----
> From: Fork Labs [mailto:forklabs@gmail.com]
> Sent: martedì 19 giugno 2007 17.58
> To: interest@jai.dev.java.net
> Subject: Re: [JAI] Cross-correlating 2 images to find
> match
>
> Hello cozytrony,
>
> A RenderedOp is a RenderedImage, you can access its
> raster by using
> method getData().
>
> To be able to see the result of you DFT's, it is
> usually viewed after
> a call to operator "periodicshift" (it will center
> the DFT).
>
> Regards,
>
> Daniel Léonard
>
> ------------------------------------------------------
> ---------------
> 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

cozytrony
Offline
Joined: 2007-06-19
Points: 0

Hi ppl,

Btw anyone noes how i can make sense of the the Rastor object, retrieve from the cross-correlated RenderedOp object using " RenderedOp.getData() ", to check the statistical match of 2 images (baseImage, matchTemplate)?

any help will be very much appreciated!

Yours Sincerely
Cozytrony

bpb
Offline
Joined: 2004-06-23
Points: 0

I don't know exactly what you are asking here, but in general one would inspect the values in the cross-correlation image to find a peak value which will indicate the location of the match. Sometimes this is not simple. It might be necessary for example to fit a bivariate polynomial to the correlation values and use its peak to get the subpixel location.

> Hi ppl,
>
> Btw anyone noes how i can make sense of the the
> Rastor object, retrieve from the cross-correlated
> RenderedOp object using " RenderedOp.getData() ", to
> check the statistical match of 2 images (baseImage,
> matchTemplate)?
>
> any help will be very much appreciated!
>
> Yours Sincerely
> Cozytrony

cozytrony
Offline
Joined: 2007-06-19
Points: 0

Hi bpb,

actually i'm on a project that has to do with tracking a person's motion within a small confined area if that will give u a better picture.

I was thinking of using CC to match a database of the subject's images to the real-time video and in a sense track and identify the target in the given room.

But right now i am jammed stucked at trying to figure out how to make sense of the CC data, looks like i have 2 types of CC data a
1. awt.Image (PlanarImage.getAsBufferedImage) and a
2. image.Rastor (PlanarImage.getData())

that i can derive from the CC- PlanarImage.

>I don't know exactly what you are asking here, but in general one would inspect the
>values in the cross-correlation image to find a peak value which will indicate the
>location of the match.
You mentioned this, but I'm not exactly sure what technique to use and find the peak value? possible to elaborate more on it? will appreciate it! As mentioned above i have the awt.Image and image.Rastor data of the CC from the 2 images.

>bivariate polynomial to the correlation values and use its peak to get the subpixel
>location.
I'm not familiar with the know how on performing bivariate polynomial onto correlation values.. its probably time consuming to explain this part but, would you mind to guide me in the direction with which i can research it on? thank you!

Any help would be appreciated!

Yours Sincerely
Cozytrony

Fork Labs

Hello cozytrony,

A RenderedOp is a RenderedImage, you can access its raster by using
method getData().

To be able to see the result of you DFT's, it is usually viewed after
a call to operator "periodicshift" (it will center the DFT).

Regards,

Daniel Léonard

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

cozytrony
Offline
Joined: 2007-06-19
Points: 0

Hi daniel,

thanks for the prompt reply!

i've played with the periodicShift parameter function with shiftX and shiftY, instead of the
gibberish i see prior to this, now i see bands of lines, what does this lines mean?

And do i periodicShift first then proceed to get the raster data " getData() ", or the other way round, when i need to get the correct rastor data of cross-correlation of the 2 image?

sorry for being ignorant, i am very new to JAI just started a day back.

Yours Sincerely
Cozytrony

Fork Labs

Hello Cozytrony,

> gibberish i see prior to this, now i see bands of lines, what does
> this lines mean?

You will have to read on the Fourier Transform to be able to interpret
the data. There is much more than a simple email can do.

> And do i periodicShift first then proceed to get the raster data
> " getData() ", or the other way round, when i need to get the
> correct rastor data of cross-correlation of the 2 image?

I know nothing about cross-correlation but I would guess that both
your image and the template should be at the same state.

Regards,

Daniel Léonard

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

cozytrony
Offline
Joined: 2007-06-19
Points: 0

Hi daniel,

i guess i'll get back to fourier transform first for now then, thanks for the prompt reply!

Regards,
Cozytrony