I am trying to sum up all the values in a 400 x 640 image that are within a masked region using the roifilt2
function. I created a mask using roipoly
and it is also stored as a 400 x 640 matrix with 0's in the cells I am uninterested in and 1's in the cells that I wish to sum up.
I was wondering how you would go about this, I have looked at the mathworks page for roifilt2
but I don't understand how to pass the sum function into this properly. This is what I'm trying:
fh = @(I)(sum(I,2));
I2 = roifilt2(I, mask, fh);
where I is my image and mask is my mask. I also keep getting the following error, even though my I and my mask are DEFINITELY the same size:
Error using roifilt2 (line 79)
The filtered image is not the same size as the original image.
Any help would be appreciated, Thanks!