0% found this document useful (0 votes)
18 views

%interaccionprsonal

The document loads and preprocesses several images, applies thresholding and morphological operations to convert them to binary images, and then uses regionprops to extract various features from the connected components in the images. It plots the original and processed images and extracts features like area, centroid, bounding box, major/minor axis lengths, etc. for each connected component. The extracted features are written out to an Excel file.

Uploaded by

Rosalia Flores C
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

%interaccionprsonal

The document loads and preprocesses several images, applies thresholding and morphological operations to convert them to binary images, and then uses regionprops to extract various features from the connected components in the images. It plots the original and processed images and extracts features like area, centroid, bounding box, major/minor axis lengths, etc. for each connected component. The extracted features are written out to an Excel file.

Uploaded by

Rosalia Flores C
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

clc

clear all
close all
clc
clear all
I=imread('Koala.jpg');
I=uint8(I);
figure(1),imshow(I),
J=rgb2gray(I)
figure(2),imshow(J),
level=graythresh(J),
BW=im2bw(J,level),
figure(3),imshow(BW),
K=im2bw(J)
figure(4),imshow(K),
%interaccionprsonal
[x y]=size(J)
for i=1:x
for j=1:y
if J(i,j)>=100
J(i,j)=1;
else
J(i,j)=0;
end
end
end
BW4=double(J);
figure(5),imshow(BW4);
clc
clear all
close all
BW=imread('haba.tif');
figure(1),imshow(BW);
BW=uint8(BW);
BW=rgb2gray(BW);
figure(2),imshow(BW);
level = graythresh(BW);
BW =im2bw(BW,level);
figure(3),imshow(BW);
L=medfilt2(BW,[3 3]);
figure(4),imshow(L)
[labeled,Objects] = bwlabel(BW,4);
granulo = regionprops(labeled,'all');
[x y]=size(BW);

for i = 1 : Objects

area1(i,:)=granulo(i).Area;
centroide1(i,:)=granulo(i).Centroid;
boundingbox1(i,:)=granulo(i).BoundingBox;
%subarrayidex1=granulo(i).SubarrayIdex;
majoraxislength1=granulo(i).MajorAxisLength;
minoraxislength1=granulo(i).MinorAxisLength;
eccentricity1=granulo(i).Eccentricity;
orientation1(i,:)=granulo(i).Orientation;
convexhull1=granulo(i).ConvexHull;
conveximage1=granulo(i).ConvexImage;
image1=granulo(i).Image
filledimage1=granulo(i).FilledImage;
filledarea1(i,:)=granulo(i).FilledArea;
eulernumber1(i,:)=granulo(i).EulerNumber;
extrema1=granulo(i).Extrema;
equivdiameter1(i,:)=granulo(i).EquivDiameter;
solidity1(i,:)=granulo(i).Solidity;
extent1(i,:)=granulo(i).Extent;
perimeter1(i,:)=granulo(i).Perimeter;

hold on
plot(centroide1(i,1), centroide1(i,2), 'r+')

a= boundingbox1(i,1)+ boundingbox1(i,3);
b= boundingbox1(i,2)+ boundingbox1(i,4);

z(1)= boundingbox1(i,1);
w(1)= boundingbox1(i,2);
z(2)=a;
w(2)= boundingbox1(i,2);
z(3)=a;
w(3)=b;
z(4)= boundingbox1(i,1);
w(4)=b;
z(5)= boundingbox1(i,1);
w(5)= boundingbox1(i,2);

z=z';
w=w';

ss=[z w];
hold on
plot(z,w);
plot(convexhull1(:,1),convexhull1(:,2))


hold off

end
xlswrite('datos',area1,'Hoja','A1')
xlswrite('datos',centroide1,'Hoja1','B1')
xlswrite('datos',boundingbox1,'HojA','D1')
[labeled,Objects] = bwlabel(BW,4);
granulo = regionprops(labeled,'all');
[x y]=size(BW);

for i = 1 : Objects

area1(i,:)=granulo(i).Area;
centroide1(i,:)=granulo(i).Centroid;
boundingbox1(i,:)=granulo(i).BoundingBox;
%subarrayidex1=granulo(i).SubarrayIdex;
majoraxislength1=granulo(i).MajorAxisLength;
minoraxislength1=granulo(i).MinorAxisLength;
eccentricity1=granulo(i).Eccentricity;
orientation1(i,:)=granulo(i).Orientation;
convexhull1=granulo(i).ConvexHull;
conveximage1=granulo(i).ConvexImage;
image1=granulo(i).Image
filledimage1=granulo(i).FilledImage;
filledarea1(i,:)=granulo(i).FilledArea;
eulernumber1(i,:)=granulo(i).EulerNumber;
extrema1=granulo(i).Extrema;
equivdiameter1(i,:)=granulo(i).EquivDiameter;
solidity1(i,:)=granulo(i).Solidity;
extent1(i,:)=granulo(i).Extent;
perimeter1(i,:)=granulo(i).Perimeter;

hold on
plot(centroide1(i,1), centroide1(i,2), 'r+')

a= boundingbox1(i,1)+ boundingbox1(i,3);
b= boundingbox1(i,2)+ boundingbox1(i,4);

z(1)= boundingbox1(i,1);
w(1)= boundingbox1(i,2);
z(2)=a;
w(2)= boundingbox1(i,2);
z(3)=a;
w(3)=b;
z(4)= boundingbox1(i,1);
w(4)=b;
z(5)= boundingbox1(i,1);
w(5)= boundingbox1(i,2);

z=z';
w=w';

ss=[z w];
hold on
plot(z,w);
plot(convexhull1(:,1),convexhull1(:,2))


hold off

end
xlswrite('datos',area1,'Hoja1','A1')
xlswrite('datos',centroide1,'Hoja1','B1')
xlswrite('datos',boundingbox1,'Hoja1','D1')
xlswrite('datos',majoraxislength1,'Hoja1','H1')
xlswrite('datos',minoraxislength1,'Hoja1','I1')
xlswrite('datos',eccentricity1,'Hoja1','J1')
xlswrite('datos',orientacion1,'Hoja1','K1')
xlswrite('datos',filledimage1,'Hoja1','L1')
xlswrite('datos',eulernumber1,'Hoja1','M1')
xlswrite('datos',equivdiameter1,'Hoja1','N1')
xlswrite('datos',solidity1,'Hoja1','O1')
xlswrite('datos',extent1,'Hoja1','P1')
_______________-

You might also like