Skip to content

Commit

Permalink
feat: ad-hoc
Browse files Browse the repository at this point in the history
  • Loading branch information
sswellington committed Sep 22, 2020
1 parent dbd9b55 commit 39add00
Show file tree
Hide file tree
Showing 38 changed files with 300 additions and 0 deletions.
Binary file added assets/RB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/RG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/SRB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/adicao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/binaria_complemento.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/binariocomplemento.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/bin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/g.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/rb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/camadas/rg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/erosao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/histograma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prewiit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prewitt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prewittsemdilatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/program.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/rb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/resultado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/DilataMascara.m
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions src/abertura.m
Original file line number Diff line number Diff line change
@@ -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;
17 changes: 17 additions & 0 deletions src/adicao.m
Original file line number Diff line number Diff line change
@@ -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;
19 changes: 19 additions & 0 deletions src/binario.m
Original file line number Diff line number Diff line change
@@ -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);
19 changes: 19 additions & 0 deletions src/complemento_binario.m
Original file line number Diff line number Diff line change
@@ -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;
19 changes: 19 additions & 0 deletions src/contador.m
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions src/cores.m
Original file line number Diff line number Diff line change
@@ -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;
22 changes: 22 additions & 0 deletions src/d_mascara.m
Original file line number Diff line number Diff line change
@@ -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;
28 changes: 28 additions & 0 deletions src/decrease.m
Original file line number Diff line number Diff line change
@@ -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;


Binary file added src/ee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/eee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/erosion_g.m
Original file line number Diff line number Diff line change
@@ -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;
18 changes: 18 additions & 0 deletions src/histograma.m
Original file line number Diff line number Diff line change
@@ -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);
Binary file added src/m.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions src/main.m
Original file line number Diff line number Diff line change
@@ -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');
Binary file added src/q.bmp
Binary file not shown.

0 comments on commit 39add00

Please sign in to comment.