Thread Subject:
Mean of intensities between 2 points

Subject: Mean of intensities between 2 points

From: Lee ZY

Date: 1 Aug, 2013 08:47:09

Message: 1 of 3

Hi, I would like to calculate the mean intensity of the area between 2 points in a matrix. for instance,

[URL=http://imageshack.us/photo/my-images/163/qck7.jpg/][IMG]http://img163.imageshack.us/img163/7348/qck7.jpg[/IMG][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

I have 2 points at pixel-18 and pixel-28, I would like to know the value of
(val(18)+val(19)+val(20)+val(21)+val(25)+val(26)+val(27)+val(28))/8.

Points=pixel-5 and pixel-17
[URL=http://imageshack.us/photo/my-images/821/pox5.jpg/][IMG]http://img821.imageshack.us/img821/3728/pox5.jpg[/IMG][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
mean=(val(3)+val(4)+val(5)+val(10)+val(11)+val(12)+val(17)+val(18)+val(19))/9

I've tried using the hard-coded way, but there are just too many possibilities plus it is not flexible at all when the range between the points is extended. Is there any better way to compute the result? Thanks in advance!

Subject: Mean of intensities between 2 points

From: Kevin Hellemans

Date: 1 Aug, 2013 13:15:07

Message: 2 of 3

"Lee ZY" wrote in message <ktd7ad$ocp$1@newscl01ah.mathworks.com>...
> Hi, I would like to calculate the mean intensity of the area between 2 points in a matrix. for instance,
>
> [URL=http://imageshack.us/photo/my-images/163/qck7.jpg/][IMG]http://img163.imageshack.us/img163/7348/qck7.jpg[/IMG][/URL]
>
> Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
>
> I have 2 points at pixel-18 and pixel-28, I would like to know the value of
> (val(18)+val(19)+val(20)+val(21)+val(25)+val(26)+val(27)+val(28))/8.
>
> Points=pixel-5 and pixel-17
> [URL=http://imageshack.us/photo/my-images/821/pox5.jpg/][IMG]http://img821.imageshack.us/img821/3728/pox5.jpg[/IMG][/URL]
>
> Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
> mean=(val(3)+val(4)+val(5)+val(10)+val(11)+val(12)+val(17)+val(18)+val(19))/9
>
> I've tried using the hard-coded way, but there are just too many possibilities plus it is not flexible at all when the range between the points is extended. Is there any better way to compute the result? Thanks in advance!

Try this:

%% Mean between two points
% define points
pt1 = 18;
pt2 = 28;

% Create your array
NumberedArray = reshape([1:1:35],7,5);

% Find pts in array
[x1,y1] = find(NumberedArray == pt1);
[x2,y2] = find(NumberedArray == pt2);

% Calculate mean
Mean2Pts = mean(mean(NumberedArray(x1:x2,y1:y2)));

Subject: Mean of intensities between 2 points

From: Kevin Hellemans

Date: 1 Aug, 2013 13:18:06

Message: 3 of 3

Try this:
%% Mean between two points
% define points
pt1 = 18;
pt2 = 28;

% Create your array
NumberedArray = reshape([1:1:35],7,5);

% Find pts in array
[x1,y1] = find(NumberedArray == pt1);
[x2,y2] = find(NumberedArray == pt2);

% Calculate mean
Mean2Pts = mean(mean(NumberedArray(x1:x2,y1:y2)));

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
points Lee ZY 1 Aug, 2013 08:49:13
mean intensity Lee ZY 1 Aug, 2013 08:49:12
rssFeed for this Thread

Contact us