Você está na página 1de 9

>> I=imread('C:\Users\ALUMNO\Desktop\Laboratorio 3\cirline.

png'); >> G=rgb2gray(I); umb=graythresh(G); J=im2bw(G,umb); >> L4 = bwlabel(J,4); % Aplicar bwlabel en Image1 con cuatro vecinos:

L8 = bwlabel(J,8); % Aplicar bwlabel en Image1 con ocho vecinos: RGB4 = label2rgb(L4); % Una imagen se etiqueta en color figure;imshow(RGB4);

RGB8 = label2rgb(L8); % Una imagen se etiqueta en color figure;imshow(RGB8);

[labeled,numObjects] = bwlabel(J,4); % podemos contar el numero de objetos

numObjects numObjects = 9

>> data = regionprops(L8,'basic') data = 8x1 struct array with fields: Area Centroid BoundingBox

>> Area3 = data(3).Area Area3 = 489

>> allArea = [data.Area] allArea = Columns 1 through 4 441 12454 489 926

Columns 5 through 8 780 358 569 411

Calcular las propiedades estadsticas de los objetos en la imagen

>> maxArea = max([data.Area]) maxArea = 12454

>> biggestObject = find([data.Area]==maxArea)

biggestObject = 2

>> meanArea = mean([data.Area]) meanArea = 2.0535e+003

>> coin1 = im2bw (imread ('C:\Users\ALUMNO\Desktop\Laboratorio 3\coins.png')); % Primero convertimos la imagen a BW >> subplot(2,1,1);imshow(coin1);

>> coin2 = imfill (coin1, 'holes'); subplot(2,1,2);imshow(coin2);

>> [labeled,numObjects] = bwlabel(coin2,8); numObjects stats=regionprops(labeled,'Eccentricity','Area','BoundingBox'); areas=[stats.Area]

excentricidad=[stats.Eccentricity] numObjects = 10 areas = Columns 1 through 4 1683 1176 1699 1149

Columns 5 through 8 1752 1605 1647 1618

Columns 9 through 10 1201 1182

excentricidad = Columns 1 through 5 0.3494 0.3415 0.3005 0.3411 0.3099

Columns 6 through 10 0.3298 0.3224 0.3226 0.3387 0.3291

>> I = double(imread('C:\Users\ALUMNO\Desktop\Laboratorio 3\rice.png')); >> % Despliegue en pantalla de la imagen figure imshow(I,[]) title('Arroces') xlabel('j'); ylabel('i');

% Despliegue del perfil de una linea disp('Marque con el mouse una linea en la imagen...') improfile title('Tonos de gris de la linea marcada') disp('presione <enter> para continuar...') pause

% Despliegue de los tonos de gris en 3D figure mesh(double(I)) view(129,78) title('Despliegue 3D') xlabel('j'); ylabel('i'); zlabel('Tonos de gris'); disp('presione <enter> para continuar...') pause

% Despliegue del histograma figure imhist(uint8(fix(I))) title('Histograma') xlabel('Tonos de gris'); ylabel('Frecuencia'); disp('presione <enter> para continuar...') pause

>> I=imread('C:\Users\ALUMNO\Desktop\Laboratorio 3\cirline.png'); G=rgb2gray(I); umb=graythresh(G); J=im2bw(G,umb); dia=strel('diamond',5); >> J2=imopen(JI,dia); >> figure; imshow(J2);

>> L4 = bwlabel(J2,4);

% Aplicar bwlabel en Image1 con cuatro vecinos:

>> RGB4 = label2rgb(L4); % Una imagen se etiqueta en color >> figure;imshow(RGB4);

>> [labeled,numObjects] = bwlabel(J2,4); % podemos contar el numero de objetos >> numObjects numObjects = 14

Você também pode gostar