0

I have two images - one binarized, and one original.

I use the binarized image to segment using bwconncomp and then for every blob/region, I want to sum the pixel-intensities from the original image.

I do that by:

blobMeasurements = regionprops(binarizedImage, originalImage, 'pixelvalues');

Now, I have a struct with a 'p x 1' vector for each blob/region. I need to sum these pixel intensities, such that I have one 'sum' value for each blob/region. How do I perform this operation? Is there a better way of doing this?

Thanks.

Sovm
  • 51
  • 7

1 Answers1

0

Try this:

blobIntensities = arrayfun(@(x) sum(x.pixelvalues(:)), blobMeasurements);

arrayfun runs the given function @(x) sum(x.pixelvalues(:)) on each of the pelement of the structure array blobMeasurements. Hope this helps.

souty
  • 607
  • 3
  • 10
  • Nope: >>>Undefined function 'sum' for input arguments of type 'struct'. >>>Error in @(x)sum(x(:)) – Sovm May 16 '17 at 15:13