COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### normalized cross correlation(NCC)

• Follow

```Hi,

I would like to perform normalized cross correlation(NCC) using color images, this is how i am doing;

As i have to compare different patches of same size (100x200) and then find those patches with max value (i.e highest NCC value) in between them

Problem:

I have color image so i apply NCC one by one on all channels and then take the max in this way i get three different values i.e C_red,C_green,C_blue so i simply add them to get the average value

C_red = max(max(normxcorr2(patches1, patches2);
C_green= max(max(normxcorr2(patches1, patches2);
C_blue= max(max(normxcorr2(patches1, patches2);
c=(C_red+C_green+C_blue)/3

But averaging the three color channels might not be optimal, so in this case it might be possible (because you loose information with this) to find the MAX in a wrong patch.

Any suggestions how to avoid averaging ? or any other idea

```
 0

```"qureshi 497" <qureshi497@yahoo.com> wrote in message <ibeg5h\$8lr\$1@fred.mathworks.com>...
> Hi,
>
> I would like to perform normalized cross correlation(NCC) using color images, this is how i am doing;
>
> As i have to compare different patches of same size (100x200) and then find those patches with max value (i.e highest NCC value) in between them
>
> Problem:
>
> I have color image so i apply NCC one by one on all channels and then take the max in this way i get three different values i.e C_red,C_green,C_blue so i simply add them to get the average value
>
> C_red = max(max(normxcorr2(patches1, patches2);
> C_green= max(max(normxcorr2(patches1, patches2);
> C_blue= max(max(normxcorr2(patches1, patches2);
> c=(C_red+C_green+C_blue)/3
>
> But averaging the three color channels might not be optimal, so in this case it might be possible (because you loose information with this) to find the MAX in a wrong patch.
>
> Any suggestions how to avoid averaging ? or any other idea
>

Hi,

if this is your code, then  C_red,C_green,C_blue are calculated in the same way and have the same value. I think you copy the colors to patches1 and patches2?

but if you want to avoid the averaging you could produce one image out of the color channels which you set to mean 0 and standard deviation 1 seperately before. Problem in both considerations: you normalize the channels seperately and therefore loose the color information which consists of ratios of the color values.

maybe it helps to combine your color channels and do the normalization afterwards.

Best
kinor
```
 0

```"kinor " <kinor.removethiswithdot@gmx.de> wrote in message <ibeh4o\$djf\$1@fred.mathworks.com>...
> "qureshi 497" <qureshi497@yahoo.com> wrote in message <ibeg5h\$8lr\$1@fred.mathworks.com>...
> > Hi,
> >
> > I would like to perform normalized cross correlation(NCC) using color images, this is how i am doing;
> >
> > As i have to compare different patches of same size (100x200) and then find those patches with max value (i.e highest NCC value) in between them
> >
> > Problem:
> >
> > I have color image so i apply NCC one by one on all channels and then take the max in this way i get three different values i.e C_red,C_green,C_blue so i simply add them to get the average value
> >
> > C_red = max(max(normxcorr2(patches1, patches2);
> > C_green= max(max(normxcorr2(patches1, patches2);
> > C_blue= max(max(normxcorr2(patches1, patches2);
> > c=(C_red+C_green+C_blue)/3
> >
> > But averaging the three color channels might not be optimal, so in this case it might be possible (because you loose information with this) to find the MAX in a wrong patch.
> >
> > Any suggestions how to avoid averaging ? or any other idea
> >
>
> Hi,
>
> if this is your code, then  C_red,C_green,C_blue are calculated in the same way and have the same value. I think you copy the colors to patches1 and patches2?
>
> but if you want to avoid the averaging you could produce one image out of the color channels which you set to mean 0 and standard deviation 1 seperately before. Problem in both considerations: you normalize the channels seperately and therefore loose the color information which consists of ratios of the color values.
>
> maybe it helps to combine your color channels and do the normalization afterwards.
>
> Best
> kinor

C_red,C_green,C_blue do not have same values. Actually i divide the color image of size 512x512 into (100 rows and 200 columns) patches. So in patches 1 and 2, i already have the color informatiion in it.

i did try to apply normalization (NCC) on the whole image (i.e color image with rgb values) but i cannot apply NCC on the image having three dimensions as i use matlab command (i.e normxcorr2) which works only on gray scale image please see link step 3:
http://www.mathworks.com/products/imageb/indexb.html?sec=tour&subsec=demo&file=/products/demos/shipping/images/ipexnormxcorr2.html

So thats why i apply NCC seperately on each channel one by one. And then do averaging to get one value (i.e i simply average the three max values from rgb channels which i get after NCC)and then i compare this value with the max values (i get from other patches) and select that patch. which has highest NCC value among them.
Any suggestions ?
```
 0

```"qureshi 497" <qureshi497@yahoo.com> wrote in message <iberih\$e9b\$1@fred.mathworks.com>...
> "kinor " <kinor.removethiswithdot@gmx.de> wrote in message <ibeh4o\$djf\$1@fred.mathworks.com>...
> > "qureshi 497" <qureshi497@yahoo.com> wrote in message <ibeg5h\$8lr\$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I would like to perform normalized cross correlation(NCC) using color images, this is how i am doing;
> > >
> > > As i have to compare different patches of same size (100x200) and then find those patches with max value (i.e highest NCC value) in between them
> > >
> > > Problem:
> > >
> > > I have color image so i apply NCC one by one on all channels and then take the max in this way i get three different values i.e C_red,C_green,C_blue so i simply add them to get the average value
> > >
> > > C_red = max(max(normxcorr2(patches1, patches2);
> > > C_green= max(max(normxcorr2(patches1, patches2);
> > > C_blue= max(max(normxcorr2(patches1, patches2);
> > > c=(C_red+C_green+C_blue)/3
> > >
> > > But averaging the three color channels might not be optimal, so in this case it might be possible (because you loose information with this) to find the MAX in a wrong patch.
> > >
> > > Any suggestions how to avoid averaging ? or any other idea
> > >
> > > thanks in advance
> >
> > Hi,
> >
> > if this is your code, then  C_red,C_green,C_blue are calculated in the same way and have the same value. I think you copy the colors to patches1 and patches2?
> >
> > but if you want to avoid the averaging you could produce one image out of the color channels which you set to mean 0 and standard deviation 1 seperately before. Problem in both considerations: you normalize the channels seperately and therefore loose the color information which consists of ratios of the color values.
> >
> > maybe it helps to combine your color channels and do the normalization afterwards.
> >
> > Best
> > kinor
>
> C_red,C_green,C_blue do not have same values. Actually i divide the color image of size 512x512 into (100 rows and 200 columns) patches. So in patches 1 and 2, i already have the color informatiion in it.
>
> i did try to apply normalization (NCC) on the whole image (i.e color image with rgb values) but i cannot apply NCC on the image having three dimensions as i use matlab command (i.e normxcorr2) which works only on gray scale image please see link step 3:
> http://www.mathworks.com/products/imageb/indexb.html?sec=tour&subsec=demo&file=/products/demos/shipping/images/ipexnormxcorr2.html
>
> So thats why i apply NCC seperately on each channel one by one. And then do averaging to get one value (i.e i simply average the three max values from rgb channels which i get after NCC)and then i compare this value with the max values (i get from other patches) and select that patch. which has highest NCC value among them.
> Any suggestions ?

mmhh maybe

sz = size(im);
ccim = reshape(im, sz(1), sz(2)* 3);
use ccim for cross correlation..
```
 0

3 Replies
822 Views

Similiar Articles:

7/27/2012 2:43:53 PM