MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by pammy on 31 Mar 2013

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

Answer by Image Analyst on 31 Mar 2013

Accepted answer

What about this:

correlationImage = xcorr2(block53, block32);

Show 8 older comments

pammy on 3 Apr 2013

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

Image Analyst on 3 Apr 2013

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.

## 0 Comments