rows = 240;columns = 320;
grayImage = zeros(rows, columns, 'uint8');
xCoords = [100 200 300];
yCoords = [80 160 80];
mask = poly2mask(xCoords, yCoords, rows, columns);
grayImage(mask) = 150; % or whatever value you want.
imshow(grayImage);
>> B=im2bw(grayImage);
>> figure,imshow(B);
>> C=imfill(B,'holes');
>> figure,imshow(C);
>> [Label,Total]=bwlabel(C,8);
>> figure,imshow(C);
grayImage = zeros(rows, columns, 'uint8');
xCoords = [100 200 300];
yCoords = [80 160 80];
mask = poly2mask(xCoords, yCoords, rows, columns);
grayImage(mask) = 150; % or whatever value you want.
imshow(grayImage);
>> B=im2bw(grayImage);
>> figure,imshow(B);
>> C=imfill(B,'holes');
>> figure,imshow(C);
>> [Label,Total]=bwlabel(C,8);
>> figure,imshow(C);
how is xcoords and ycoords variables selected
ReplyDelete