Thread Subject:
how to randomly select pixels from an image

Subject: how to randomly select pixels from an image

From: Jennifer Faggi Renault

Date: 5 Apr, 2010 14:28:07

Message: 1 of 6

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

Subject: how to randomly select pixels from an image

From: us

Date: 5 Apr, 2010 15:00:21

Message: 2 of 6

"Jennifer Faggi Renault" <asma_192@live.fr> wrote in message <hpcs1n$38u$1@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

Subject: how to randomly select pixels from an image

From: Jennifer Faggi Renault

Date: 5 Apr, 2010 15:30:26

Message: 3 of 6

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

Subject: how to randomly select pixels from an image

From: us

Date: 5 Apr, 2010 15:39:04

Message: 4 of 6

"Jennifer Faggi Renault" <asma_192@live.fr> wrote in message <hpcvmi$464$1@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

Subject: how to randomly select pixels from an image

From: ImageAnalyst

Date: 5 Apr, 2010 15:45:19

Message: 5 of 6

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.

Subject: how to randomly select pixels from an image

From: Jennifer Faggi Renault

Date: 5 Apr, 2010 15:49:04

Message: 6 of 6

thanks again :)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
linear indexing us 5 Apr, 2010 11:04:09
randperm us 5 Apr, 2010 11:04:09
code us 5 Apr, 2010 11:04:09
select randomly Jennifer Faggi Renault 5 Apr, 2010 10:29:23
image Jennifer Faggi Renault 5 Apr, 2010 10:29:23
adjacent pixels Jennifer Faggi Renault 5 Apr, 2010 10:29:23
correlation Jennifer Faggi Renault 5 Apr, 2010 10:29:23
rssFeed for this Thread

Contact us