1
votes

I am trying to add 2 binary masks of the same image for overlap ratio calculation I create the binary masks as such:

mask1 = roipoly(image,points1(:,1),points1(:,2))
mask2 = roipoly(image,points2(:,1),points2(:,2))
imwrite(mask1,'mask1.bmp')
imwrite(mask2,'mask2.bmp')

points1 and points2 are 2 different matrices of segmentation coordinates of the same size

When I try to do the following, i get Matrix dimension must agree error using plus

a=('mask1.bmp')
b=('mask2.bmp')
a+b

When i check the sizes of a and b they give same values but somehow the matrix dimensions don't agree

2
Can you check the example code? As is, the a+b is adding the characters of two strings together, and does not error.Andrew Janke
There is image build-in function in MATLAB. Don't use it as a variable name.yuk

2 Answers

1
votes

It can be written as:

c=mask1+mask2;
imshow(c);
0
votes

You forgot imread

a=imread('mask1.bmp')
b=imread('mask2.bmp')