Skip to content

Instantly share code, notes, and snippets.

@vitorbaptista
Created July 7, 2010 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitorbaptista/466177 to your computer and use it in GitHub Desktop.
Save vitorbaptista/466177 to your computer and use it in GitHub Desktop.
# Magentinizator v 0.42 - 2009
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revisão 42):
# <vitor@vitorbaptista.com> escreveu este arquivo. Contanto que mantenha este
# texto, você pode fazer o que quiser com esse software. Se nos conhecermos
# algum dia, e você achar que esse programa vale, você pode me pagar uma cerveja
# em troca.
# Vitor Baptista
# ----------------------------------------------------------------------------
path = "uepb.png"; # Caminho para a imagem
threshold = 0xB4; # Pixels com cor maior que 0xB4B4B4
# se tornarão 0xFF00FF
im = imread(path); # Lê a imagem. im agora tem uma matriz
# Largura x Altura x 3 (RGB)
tam = size(im); # Pega o tamanho da imagem
for i = 1:tam(1) # De 1 até a largura
for j = 1:tam(2) # De 1 até a altura
if (im(i, j, 1) > threshold # Se o R for maior que o threshold, e
&& im(i,j,2) > threshold # se o G for maior, e
&& im(i,j,3) > threshold) # se o B for maior.
im(i,j,1) = 255; # Torna aquele pixel
im(i,j,2) = 0; # em
im(i,j,3) = 255; # magenta!
end
end
end
imwrite([path, ".magentinized"], # Concatena strings
im(:,:,1), # R
im(:,:,2), # G
im(:,:,3)); # B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment