Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all;
- clear all;
- rgb = imread('gambar1.jpeg');
- [imageRows, imageColumns, colorChannels] = size(rgb);
- subplot(1,2,1);
- imshow(rgb,[]);
- axis on;
- title('Original');
- crgb = imadjust(rgb, [0.3 0.7], []);
- F = griddedInterpolant(double(crgb));
- [sx,sy,sz] = size(crgb);
- xq = (0:5:sx)';
- yq = (0:5:sy)';
- zq = (1:sz)';
- rescrgb = uint8(F({xq,yq,zq}));
- subplot(1,2,2);
- imshow(rescrgb);
- axis on;
- title('Resample');
- r = rescrgb(:,:,1);
- g = rescrgb(:,:,2);
- b = rescrgb(:,:,3);
- redMask = r > 250 & g < 90 & b < 90;
- blueMask = r < 50 & g > 170 & b > 200;
- greenMask = r < 180 & g > 200 & b < 220;
- orangeMask = r > 100 & g > 100 & b < 80;
- pinkMask = r > 220 & g < 100 & b > 200;
- violetMask = r > 220 & (g < 220 & g > 205) & b > 200;
- figure();
- subplot(2, 3, 1);
- imshow(redMask);
- title('redMask');
- subplot(2,3,3);
- imshow(blueMask);
- title('blueMask');
- subplot(2,3,2);
- imshow(greenMask);
- title('greenMask');
- subplot(2,3,4);
- imshow(orangeMask);
- title('orangeMask');
- subplot(2,3,5);
- imshow(pinkMask);
- title('pinkMask');
- subplot(2,3,6);
- imshow(violetMask);
- title('violetMask');
- redBlob = conv2(double(redMask), ones(30, 30));
- greenBlob = conv2(double(greenMask), ones(30, 30));
- blueBlob = conv2(double(blueMask), ones(30, 30));
- orangeBlob = conv2(double(orangeMask), ones(30, 30));
- pinkBlob = conv2(double(pinkMask), ones(30, 30));
- violetBlob = conv2(double(violetMask), ones(30, 30));
- figure();
- subplot(2, 3, 1);
- imshow(redBlob);
- title('redBlob');
- subplot(2, 3, 2);
- imshow(greenBlob);
- title('greenBlob');
- subplot(2, 3, 3);
- imshow(blueBlob);
- title('blueBlob');
- subplot(2, 3, 4);
- imshow(orangeBlob);
- title('orangeBlob');
- subplot(2, 3, 5);
- imshow(pinkBlob);
- title('pinkBlob');
- subplot(2, 3, 6);
- imshow(violetBlob);
- title('violetBlob');
- [R, redCount] = bwlabel(redBlob, 8);
- [G, greenCount] = bwlabel(greenBlob, 8);
- [B, blueCount] = bwlabel(blueBlob, 8);
- [O, orangeCount] = bwlabel(orangeBlob, 8);
- [P, pinkCount] = bwlabel(pinkBlob, 8);
- [V, violetCount] = bwlabel(violetBlob, 8);
- Red = redCount
- Green = greenCount
- Blue = blueCount
- Orange = orangeCount
- Pink = pinkCount
- Violet = violetCount
- Total = Red + Green + Blue + Orange + Pink + Violet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement