Why is there a problem with the third input parameter of "lazysnapping"? I think it is an integer value.
RGB = imread('peppers.png');
L = superpixels(RGB,500);
[h,w,c] = size(RGB);
figure
imshow(RGB)
h1 = drawpolyline('Color','green');
roiPoints1 = h1.Position;
h2 = drawpolyline('Color','blue');
roiPoints2 = h2.Position;
foregroundInd = sub2ind([h,w],roiPoints1(:,2),roiPoints1(:,1));
backgroundInd = sub2ind([h,w],roiPoints2(:,2),roiPoints2(:,1));
BW = lazysnapping(RGB,L,foregroundInd,backgroundInd);
figure
imshow(BW)
maskedImage = RGB;
maskedImage(repmat(~BW,[1 1 3])) = 0;
figure;
imshow(maskedImage)
Error using lazysnapping
Expected input number 3, foreground, to be integer-valued.
Error in lazysnapping>validateInputs (line 248)
validateattributes(foreground,validMaskTypes,{'nonnan','nonsparse', ...
Error in lazysnapping (line 158)
[foregroundInd,backgroundInd,is3D] = validateInputs(A,L,foreground,background);
Error in faceCropID (line 20)
BW = lazysnapping(RGB,L,foregroundInd,backgroundInd);