i dont know how to calculate the coorelation of corresponding pixels of the blocks that have the same value.

i've divided the image into discrete blocks and then i've calculated the corresponding mean value of each and every block. the mean value of some of the blocks are same or some have different value i.e block 32,43 and 65 have same value, block 67,89 and 12 have same value.
now i want to calculate the coorelation of corresponding pixels of the blocks that have the same value i.e.
the correlation between the first pixels of 32,43 and 65 block.....then correlation among second pixels of these blocks and so on....then avg these
values......
as i m novice i dont know how to calculate the correlation of corresponding pixels of the block...

 Respuesta aceptada

What about this:
correlationImage = xcorr2(block53, block32);

11 comentarios

sir xcorr2 calculates the correlation of only 2 blocks 53 and 32...
As i told u earlier, those blocks whose values are same i've stored it in array [32 43 65] this is one set and [56 21 78 43] this is second set and so on.....
what to do if i want to calculate the correlation between the first pixel of block 32,block 43 and block 65....and then correlation among second pixel of these blocks and so on..
and then average these pixels...
So put it in a loop or something. Obviously you know what specific blocks need to be compared.
ok sir ..i can put it in a loop but the function 'xcorr2' function takesonly two argument...
like i've a set
block= [block32 block43 block65] i've to find the correlation of this...
for i=1:len(block)
correlation=xcorr2(block32,block43)
end
the loop i can adjust according to my program...when i m going to calculate the coorelation at that time i've to pair the blocks one by one or not?
i.e correlation=xcorr2(block32,block43) correlation=xcorr2(block43,block65) and so on....
or if it is incorrect plz correct it by taking the set [32 43 65] rest i can generalize according to my program
Have two loops
for k1 = 1:length(blockNumbers)
blockNumber1 = blocks{k1}; % Extract image block #1
for k2 = k1:length(blockNumbers)
blockNumber2 = blocks{k2}; % Extract image block #2
% Now correlate the two small images.
correlation=xcorr2(blockNumber1, blockNumber2);
% Save it or whatever...
end
end
block{k1} is showing error
Cell contents reference from a non-cell array object.
here blocks is what? in my case is this my input image or my array name in which m storing blocks???
k1 and k2 are look indexes. blockNumbers is the list of blocks you want to compare, for example for one set of numbers it would be [32 43 65]. But it might be another set for some different set that you want to compare, like [23,45,67], or [21,65], or [87,43,12]. The code I gave you only does all the permutations for one set, which is given in blockNumbers. You'd have to do that loop for each set of block numbers. This can be done in a loop if all your block numbers sets are in an array.
ok sir....
block{k1} shows an error...
here block is what? block is that where i stored the list of array elements right?
i.e block=[block32 block43 block65]
for list of block36 and block 107 it shows three values of correlation is it correct?
i mean for set [block36 block 107] it shows 3 values of correlation
for set [block86 block94 block110] it shows 6 values of correlation
for set [block54 block126 block134 block144] it shows 10 values of correlation
is this permutation results are correct?
also sir correlation lies between +1 and -1 but the values i got is beyond 1000 which is wrong
i've used theur code in my code as:
[S,blockNumber]=sort(glcmmean);
u=unique(S(:));
for i=1:length(u)
matchIndex=(S(:)==u(i));
count=length(find(S(:)==u(i)));
%disp(matchIndex);
matchBlock=blockNumber(matchIndex);
if(count>1)
fprintf('\nblock')
fprintf(' %d ',matchBlock);
[B1]=matchBlock;
L=length(B1);
for k1=1:L
blck1=B1(k1);
for k2=k1:L
blck2=B1(k2);
correlation=xcorr2(blck1,blck2);
fprintf('\ncorrelation %f',correlation);
end
end
here 'S' stores all the GLCM MEAN values.
'u' = extract uniques values from S( from GLCM MEAN values)
'matchIndex' is where S and u finds the same value i.e match
'count' is the variable which gives the length of elements having same value i.e block32 block 45 and block67 having same GLCM MEAN value so its count will be 3 and so on....
i m interested in the count values which have blocks >1. thats y i've used the condition if(count>1)
B1 is the set of array i.e at one time it will be [block32 block45 block 65](because of glcm mean values are same i.e 1241).
next i've calculated the correlation as u told me...
plz check it that it is correct or not.. if it is incorrect then plz help me by correcting it...
I'm sorry I can't spend as much time on your project as you'd want me to. I don't know how you get your blocks. Maybe you used mat2cell or something. But however you got them, you have to get them into two arrays so that you can pass them into xcorr2(). Whether that is by pulling them out of a cell in a cell array or pulling them out of a plane of a 3D image, I don't know. Do whatever you have to do to get the two sub-images. I don't have time to figure that part out for you. Sorry.
sir m not using mat2cells, m using indexing techniques like:
image(row1:row2,col1:col2);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 31 de Mzo. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by