Showing posts with label morphology. Show all posts
Showing posts with label morphology. Show all posts

Tuesday, 26 August 2014

morphology operations top hat and bottom hat

 I = im2single(imread('rice.png'));
 htop = vision.MorphologicalTopHat('Neighborhood',strel('disk', 12));

% Improve contrast of output image
   hc = vision.ContrastAdjuster;  J = step(htop,I);
  J = step(hc,J);
  figure;

 subplot(1,2,1),imshow(I); title('Original image');
 subplot(1,2,2),imshow(J);
 title('Top-hat filtered image');




I = im2single(b);
 hbot = vision.MorphologicalBottomHat('Neighborhood',strel('disk', 5));
 J = step(hbot,I);
 figure;
 subplot(1,2,1),imshow(I); title('Original image');
 subplot(1,2,2),imshow(J);
 title('Bottom-hat filtered image'); 

Friday, 11 July 2014

morphology operations

clear all
close all
a=imread('cell1.bmp'); % reads the image
b=im2bw(a); %convert to binary
b1=bwareaopen(b,550); % remove connected components from a binary image
b2=imfill(b1,'holes'); % fill the region
%dialte
se=strel('disk',3,6); %structuring elt default:4
d1=imdilate(b2,se);
%imerode
se1=strel('disk',11);
d2=imerode(d1,se1);
%contour
p=bwmorph(d1,'remove');
perimeter=sum(sum(p));
figure(1);imshow(a);
figure(2);imshow(b1);
figure(3);imshow(d1);
figure(4);imshow(d2);
figure(5);imshow(p);
fprintf('perimeter of the shape');
disp(perimeter)

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