diff --git a/assets/RB.png b/assets/RB.png new file mode 100644 index 0000000..f0dfdf6 Binary files /dev/null and b/assets/RB.png differ diff --git a/assets/RG.png b/assets/RG.png new file mode 100644 index 0000000..4995086 Binary files /dev/null and b/assets/RG.png differ diff --git a/assets/SRB.png b/assets/SRB.png new file mode 100644 index 0000000..18eb5f0 Binary files /dev/null and b/assets/SRB.png differ diff --git a/assets/adicao.png b/assets/adicao.png new file mode 100644 index 0000000..4a49beb Binary files /dev/null and b/assets/adicao.png differ diff --git a/assets/binaria_complemento.png b/assets/binaria_complemento.png new file mode 100644 index 0000000..21aad68 Binary files /dev/null and b/assets/binaria_complemento.png differ diff --git a/assets/binariocomplemento.png b/assets/binariocomplemento.png new file mode 100644 index 0000000..7b3a97f Binary files /dev/null and b/assets/binariocomplemento.png differ diff --git a/assets/camadas/b.png b/assets/camadas/b.png new file mode 100644 index 0000000..f28b741 Binary files /dev/null and b/assets/camadas/b.png differ diff --git a/assets/camadas/bg.png b/assets/camadas/bg.png new file mode 100644 index 0000000..9df5534 Binary files /dev/null and b/assets/camadas/bg.png differ diff --git a/assets/camadas/bin.png b/assets/camadas/bin.png new file mode 100644 index 0000000..400ca3a Binary files /dev/null and b/assets/camadas/bin.png differ diff --git a/assets/camadas/g.png b/assets/camadas/g.png new file mode 100644 index 0000000..35a8b0f Binary files /dev/null and b/assets/camadas/g.png differ diff --git a/assets/camadas/r.png b/assets/camadas/r.png new file mode 100644 index 0000000..feed4b8 Binary files /dev/null and b/assets/camadas/r.png differ diff --git a/assets/camadas/rb.png b/assets/camadas/rb.png new file mode 100644 index 0000000..beafc7a Binary files /dev/null and b/assets/camadas/rb.png differ diff --git a/assets/camadas/rg.png b/assets/camadas/rg.png new file mode 100644 index 0000000..432a3a5 Binary files /dev/null and b/assets/camadas/rg.png differ diff --git a/assets/erosao.png b/assets/erosao.png new file mode 100644 index 0000000..7003670 Binary files /dev/null and b/assets/erosao.png differ diff --git a/assets/histograma.png b/assets/histograma.png new file mode 100644 index 0000000..8e2502c Binary files /dev/null and b/assets/histograma.png differ diff --git a/assets/mask.png b/assets/mask.png new file mode 100644 index 0000000..661afa4 Binary files /dev/null and b/assets/mask.png differ diff --git a/assets/prewiit.png b/assets/prewiit.png new file mode 100644 index 0000000..1d39897 Binary files /dev/null and b/assets/prewiit.png differ diff --git a/assets/prewitt.png b/assets/prewitt.png new file mode 100644 index 0000000..fb83ff4 Binary files /dev/null and b/assets/prewitt.png differ diff --git a/assets/prewittsemdilatar.png b/assets/prewittsemdilatar.png new file mode 100644 index 0000000..5a7df5b Binary files /dev/null and b/assets/prewittsemdilatar.png differ diff --git a/assets/program.png b/assets/program.png new file mode 100644 index 0000000..6c4b980 Binary files /dev/null and b/assets/program.png differ diff --git a/assets/rb.png b/assets/rb.png new file mode 100644 index 0000000..11d27ee Binary files /dev/null and b/assets/rb.png differ diff --git a/assets/resultado.png b/assets/resultado.png new file mode 100644 index 0000000..648edd0 Binary files /dev/null and b/assets/resultado.png differ diff --git a/src/DilataMascara.m b/src/DilataMascara.m new file mode 100644 index 0000000..d9cc763 --- /dev/null +++ b/src/DilataMascara.m @@ -0,0 +1,23 @@ +function T = DilataMascara(I,MM,EE) +%imagem, mascara, elemento + m = size(I,1); + n = size(I,2); + + A = I; + + for x = 1 : 5 + A = dilatar_g(A,EE); + %figure; imshow(A); + + for i = 1 : m + for j = 1 : n + if (MM(i,j) == 0) && (A(i,j) == 255) + A(i,j) = 0; + end + end + end + end + %A = A-MM; + + T=A; +end \ No newline at end of file diff --git a/src/abertura.m b/src/abertura.m new file mode 100644 index 0000000..a7f25d3 --- /dev/null +++ b/src/abertura.m @@ -0,0 +1,10 @@ +function[output]= abertura(I) + +% opening: erosion+dilatar + +ee = [0,255,0; 255,255,255; 0,255,0]; + +erosion = erosion_g(I,ee); +opening = dilatar_g(E,ee); + +output = opening; \ No newline at end of file diff --git a/src/adicao.m b/src/adicao.m new file mode 100644 index 0000000..1bba00d --- /dev/null +++ b/src/adicao.m @@ -0,0 +1,17 @@ +function[output]= adicao(image,sobel) + +edge_filter=filter; +swap=image; + +line_size = size(swap,1); +column_size = size(swap,2); + +temp=swap; + +for i = 1 : line_size + for j = 1 : column_size + temp(i,j,1) = swap(i,j,1)- edge_filter(i,j,1); + end +end + +output = temp; \ No newline at end of file diff --git a/src/binario.m b/src/binario.m new file mode 100644 index 0000000..49a67d4 --- /dev/null +++ b/src/binario.m @@ -0,0 +1,19 @@ + function[output]= binario(input) + +swap=input; + +line_size = size(swap,1); +column_size = size(swap,2); + +temp = swap; + + for i = 1 : line_size + for j = 1 : column_size + if temp(i,j) > 35; + D(i,j) = 255; + else + D(i,j)= 0; + end + end + end +output = uint8(D); \ No newline at end of file diff --git a/src/complemento_binario.m b/src/complemento_binario.m new file mode 100644 index 0000000..0218b63 --- /dev/null +++ b/src/complemento_binario.m @@ -0,0 +1,19 @@ + function[output]= complemento_binario(input) + +swap=input; + +line_size = size(swap,1); +column_size = size(swap,2); + +temp = swap; + + for i = 1 : line_size + for j = 1 : column_size + if temp(i,j) == 255; + D(i,j) = 0; + else + D(i,j)= 255; + end + end + end +output = D; \ No newline at end of file diff --git a/src/contador.m b/src/contador.m new file mode 100644 index 0000000..0b0480b --- /dev/null +++ b/src/contador.m @@ -0,0 +1,19 @@ +function output = contador(e) + +swap=e; + +line_size = size(swap,1); +column_size = size(swap,2); + +C = swap; + +c =0; + for i = 1 : line_size + for j = 1 : column_size + if C(i,j) == 255; + c = c + 1; + end + end + end +output = c; +end \ No newline at end of file diff --git a/src/cores.m b/src/cores.m new file mode 100644 index 0000000..83f9b33 --- /dev/null +++ b/src/cores.m @@ -0,0 +1,15 @@ +function[output]= colores(image,color) + +swap=image; +c = color; +line_size = size(swap,1); +column_size = size(swap,2); + +temp = swap; + +for i = 1 : line_size + for j = 1 : column_size + temp(i,j) = swap(i,j,c); + end +end +output = temp; \ No newline at end of file diff --git a/src/d_mascara.m b/src/d_mascara.m new file mode 100644 index 0000000..69c58f9 --- /dev/null +++ b/src/d_mascara.m @@ -0,0 +1,22 @@ +function output = d_mascara(IE,M,EE) + +% E = Imagem erodio M = Mascara EE = Elemento estruturante + +line_size = size(IE,1); +column_size = size(IE,2); + +A = IE; + +for x = 1 : 20; + A = dilatar_g(A,EE); + %figure;imshow(A); + + for i = 1 : line_size + for j = 1 : column_size + if ((M(i,j) == 0) && (A(i,j) == 255)) + A(i,j) = 0; + end + end + end +end +output = A; \ No newline at end of file diff --git a/src/decrease.m b/src/decrease.m new file mode 100644 index 0000000..9180b6a --- /dev/null +++ b/src/decrease.m @@ -0,0 +1,28 @@ + function[saida]= decrease(entrada) +% tem q salvar o arquivo c/ o nome da function +B=entrada; + +tamx = size(B,1); +tamy = size(B,2); + +C = B; +y = 1; +l = 1; + +for i = 1 : tamx/2 + %percorre a linha : + l = i*2; + for j = 1 : tamy/2 + %percorre a coluna nos numeros pares 4,6;... + y=j*2; + %4 => da o valor da claridade + D(i,j) = (B(l-1,y)/4)+ (B(l-1,y-1)/4) + (B(l,y)/4)+ (B(l,y-1)/4); + end + %zera as variaveis de coluna, para evitar o estouro de variaveis + y = 1; +end +%Tem q ser usada a variavel D, e não pode usar C, pois isso faria a foto +%subescrever-se +saida = D; + + \ No newline at end of file diff --git a/src/ee.png b/src/ee.png new file mode 100644 index 0000000..3cc3919 Binary files /dev/null and b/src/ee.png differ diff --git a/src/eee.png b/src/eee.png new file mode 100644 index 0000000..1b50328 Binary files /dev/null and b/src/eee.png differ diff --git a/src/erosion_g.m b/src/erosion_g.m new file mode 100644 index 0000000..5ced442 --- /dev/null +++ b/src/erosion_g.m @@ -0,0 +1,41 @@ +function[saida]= erosion_g(img,elemento) + +B=img; +E=elemento; + +tamx = size(B,1); +tamy = size(B,2); + +tamx_ee = size(E,1); +tamy_ee = size(E,2); + +x_ee = ceil(tamx_ee / 2); +y_ee = ceil(tamy_ee / 2); + +a= tamx_ee - x_ee; +c= tamy_ee - y_ee; + +C = B; + +for i = 1 : tamx + for j = 1 : tamy + g = -a; + h = -c; + if (B(i,j) == 255) + for x = 1 : tamx_ee + for y = 1 : tamy_ee + if(((i + g<=tamx) && (i + g > 0)) && ((j + h<=tamy) && (j + h > 0)) && (E(x_ee + g,y_ee + h) == 0)) + if(B(i+g,j+h) == 0) + C(i,j) = 0; + end + end + h = h + 1; + end + h = -c; + g = g + 1; + end + end + end +end + +saida = C; \ No newline at end of file diff --git a/src/histograma.m b/src/histograma.m new file mode 100644 index 0000000..ca3e06a --- /dev/null +++ b/src/histograma.m @@ -0,0 +1,18 @@ +function[output] = histograma(image) + +swap=(image); + +line_size = size(swap,1); +column_size = size(swap,2); + +for c = 1 : 256 + vet(c) = 0; +end + +for i = 1 : line_size + for j = 1 : column_size + vet(swap(i,j)+1) = vet(swap(i,j)+1)+1; + %vet((i+j)-1) = swap(i,j); + end +end +output = bar(vet); \ No newline at end of file diff --git a/src/m.png b/src/m.png new file mode 100644 index 0000000..6580d22 Binary files /dev/null and b/src/m.png differ diff --git a/src/main.m b/src/main.m new file mode 100644 index 0000000..c45fbc4 --- /dev/null +++ b/src/main.m @@ -0,0 +1,69 @@ +clc;clear all;close all; + +PATH = ('../img/'); + +I = imread(PATH+'w2.jpg','jpg'); +figure;imshow(I); + + +%% layer +R = cores(I,1); +%figure;imshow(R); +%title('red'); + +B = cores(I,3); +%figure;imshow(B); +%title('Blue'); + +RB = R-B; +figure;imshow(RB); +title('R-B'); + + +%% mathematical morphology +elemento2 =[255,0,255; + 0,0,0; + 255,0,255]; + +elemento = imread('eee.png','png'); + +B = binario(RB); +figure;imshow(B); +title('binario: RB'); + +BC = complemento_binario(B); +figure;imshow(BC); + +E = erosion_g(BC,elemento); +figure;imshow(E); +title('Erosion'); + +MAS = d_mascara(E,BC,elemento2); +figure;imshow(MAS); +title('MASK'); + + +%% edge detection +P = prewitt(MAS); +figure;imshow(P); +title('Prewitt'); + + +%% result +CPerimetro = contador(P) +CArea = contador(MAS) + +AD = adicao(I,P); +figure;imshow(AD); +title('Resultado'); + +% DI = RB-P; +% figure;imshow(DI); +% title('Dif'); +% +% R = BC - E; +% figure;imshow(R); +% title('R'); + +% H = histograma(RB); +% title('Histograma'); diff --git a/src/q.bmp b/src/q.bmp new file mode 100644 index 0000000..f888621 Binary files /dev/null and b/src/q.bmp differ