Matlab: Performing operations with 'struct' in image processing

84 Views Asked by At

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.

1

There are 1 best solutions below

1
On

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.