Friday, 4 July 2014

Draw triangle and apply Morphology operations on it

 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); 

1 comment: