Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> img = imread('pic.jpg');
- >> figure, imshow(img)
- >> b = rgb2gray(img);
- >> figure, imshow (b),title('original image in grayscale')
- >> c = 255-b;
- >> figure, imshow(c);title('complemented original image in grayscale')
- >> d = im2bw(c);
- >> figure, imshow(d),title('Original image in black and white')
- >> e = imfill(d,'holes');
- >> figure, imshow(e),title('Fill image in black and white')
- >> f = bwlabel(e);
- >> figure, imshow(f),title('Labelled image in black and white')
- >> vislabels(f),title('Each object labelled')
- >> g = regionprops(f, 'Area', 'BoundingBox');
- >> g(1)
- >> area_values = [g.Area]
- >> idx = find((6000 <= area_values) & (area_values <= 6500))
- >> h = ismember(f, idx);
- >> [h,num2] = bwlabel(h);
- >> figure, imshow(h), title(['tangle number: ' num2str(num2) ''])
Advertisement
Add Comment
Please, Sign In to add comment