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