From: Jennifer Faggi Renault on
Hello all,
i want to randomly select 1000 pairs of two adjacent pixels from an image to calculate their correlation coefficicent after that.
Can any one help me please cause i'm stuck here for along !!
and thanks in advance
From: us on
"Jennifer Faggi Renault" <asma_192(a)live.fr> wrote in message <hpcs1n$38u$1(a)fred.mathworks.com>...
> Hello all,
> i want to randomly select 1000 pairs of two adjacent pixels from an image to calculate their correlation coefficicent after that.
> Can any one help me please cause i'm stuck here for along !!
> and thanks in advance

one of the solutions

img=magic(4);
np=4; % <- #pairs to select...
nr=size(img,1);
rp=randperm(numel(img)-nr);
rp=rp(1:np);
plst=[img(rp).',img(rp+nr).']
%{
% plst = % <- based on current RAND state...
10 8
4 14
2 3
5 11
%}

us
From: Jennifer Faggi Renault on
i'm really thankfull for your answer.
i think that selection is for horizontally adjacent pixels.
Sorry if i bother you but, how can i change that if i want to select pairs of diagonally adjacent pixels ???
From: us on
"Jennifer Faggi Renault" <asma_192(a)live.fr> wrote in message <hpcvmi$464$1(a)fred.mathworks.com>...
> i'm really thankfull for your answer.
> i think that selection is for horizontally adjacent pixels.
> Sorry if i bother you but, how can i change that if i want to select pairs of diagonally adjacent pixels ???

well...
- just ad a one (1) to NR in the last step...
- and - make sure you check for and remove possible row-overflows...

us
From: ImageAnalyst on
Jennifer:
I think you may also be interested in the gray level co-occurrence
matrix, performed in MATLAB by the function graycomatrix() in the
Image Processing Toolbox. It basically gives the likelihood that a
gray level is next to the other 256 gray levels. You can specify the
'offset' parameter which is basically what you were asking about.