Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
image aggregation by regions

Subject: image aggregation by regions

From: Michael Lonther

Date: 25 Jan, 2008 16:06:03

Message: 1 of 2

I have two images with the same dimensions (1000 x 1000),
one image contains data values that I am trying to aggregate
and the other image contains regions (labeled 1 through 305)
over which I would like to do the aggregation in the form of
sum. In other words, I would like to sum the values of the
first image over each region and write the output as ascii.
 I do not have access to image processing toolbox.

Any help would be greatly appreciated.

Thanks..

Subject: image aggregation by regions

From: Ian Clarkson

Date: 25 Jan, 2008 17:44:03

Message: 2 of 2

"Michael Lonther" <rsbu@yahoo.com> wrote in message
<fnd1db$kdi$1@fred.mathworks.com>...
> I have two images with the same dimensions (1000 x 1000),
> one image contains data values that I am trying to
aggregate
> and the other image contains regions (labeled 1 through
305)
> over which I would like to do the aggregation in the form
of
> sum. In other words, I would like to sum the values of
the
> first image over each region and write the output as
ascii.
> I do not have access to image processing toolbox.
>
> Any help would be greatly appreciated.
>
> Thanks..

try something like this:

% generate your labels (regions)
labels=rand(10,10);
labels=round(labels*9+1);

% generate your data to be aggregated
values=rand(10,10);

% find the largest label (should be 305 in your case)
maxLabel=max(labels(:));

% loop through and find sum of all elements with those
indices
for i = 1:maxLabel
  agg(i) = sum(values(find(labels==i)));
end;

% now agg(i) contains the sum of all values labeled with
index i. ex. agg(305) contains the sum of all elements with
index 305 in the labels matrix.

Tags for this Thread

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.

Contact us