Autor Tópico: criação de imagem 3D  (Lida 1667 vezes)

Offline Kamei Hyoga

  • Usuário Ubuntu
  • *
  • Mensagens: 1.095
  • Ubuntu 11.04
    • Ver perfil
criação de imagem 3D
« Online: 29 de Agosto de 2010, 18:38 »
Estou tentando criar uma foto em 3D (ou que lembre isso hehehe) com o imagemagick. Meu problema inicial é separar a cor das imagens, para depois combinar. Parece que tenho que mover uma das imagens também, mas isso não vai ser problema.

Alguém sabe como fazer isso?

Offline ucastrobr

  • Usuário Ubuntu
  • *
  • Mensagens: 693
  • Usa Ubuntu 11.10 (Oneiric Ocelot)
    • Ver perfil
Re: criação de imagem 3D
« Resposta #1 Online: 29 de Agosto de 2010, 22:07 »
Que eu saiba para mexer com 3d tem esses dois programas.

http://www.wings3d.com/

http://www.blender.org/
Spock – "After a time, you may find that having is not so pleasing a thing, after all, as wanting. It is not logical, but it is often true."
("Depois um de tempo você vai perceber que ter algo pode não ser tão prazeroso quanto deseja-lo. Isto não é lógico, mas frequentemente é verdade.")


Offline ucastrobr

  • Usuário Ubuntu
  • *
  • Mensagens: 693
  • Usa Ubuntu 11.10 (Oneiric Ocelot)
    • Ver perfil
Re: criação de imagem 3D
« Resposta #3 Online: 30 de Agosto de 2010, 13:44 »
Usa as cores vermelho e azul para criar efeito 3D interessante.

Se dá para fazer no photoshop com certeza dá para fazer no gimp

No pothoshop como fazer

No Gimp como fazer
Spock – "After a time, you may find that having is not so pleasing a thing, after all, as wanting. It is not logical, but it is often true."
("Depois um de tempo você vai perceber que ter algo pode não ser tão prazeroso quanto deseja-lo. Isto não é lógico, mas frequentemente é verdade.")

Offline Kamei Hyoga

  • Usuário Ubuntu
  • *
  • Mensagens: 1.095
  • Ubuntu 11.04
    • Ver perfil
Re: criação de imagem 3D
« Resposta #4 Online: 30 de Agosto de 2010, 17:56 »
Vlw pelos links. Agora só preciso saber como extrair só o canal vermelho e azul da imagem e juntar num novo arquivo.

Lembrando que vou fazer isso tudo por terminal.
« Última modificação: 30 de Agosto de 2010, 18:06 por Kamei Hyoga »

Offline Kamei Hyoga

  • Usuário Ubuntu
  • *
  • Mensagens: 1.095
  • Ubuntu 11.04
    • Ver perfil
Re: criação de imagem 3D
« Resposta #5 Online: 30 de Agosto de 2010, 21:46 »
Achei um script nas minhas pesquisas:

Código: [Selecionar]
#!/bin/bash
inputfile=$1
mkdir tmp 2>/dev/null

echo "Processing $inputfile......."
outputfile=$(echo $inputfile | sed 's/[.].*$//')


#1. Create the left and right images
convert $inputfile -set option:distort:viewport -24-0 -virtual-pixel tile -distort SRT 0 +repage $outputfile-right.png
convert $inputfile -set option:distort:viewport +24-0 -virtual-pixel tile -distort SRT 0 +repage $outputfile-left.png


#2. Left image, need to crop right side, right image crop left side
convert $outputfile-left.png -gravity east -chop 24x0 $outputfile-leftA.png
convert $outputfile-right.png -chop 24x0 $outputfile-rightA.png


#3. Resize to 640x480
convert $outputfile-leftA.png -resize 640x480! $outputfile-leftAA.png
convert $outputfile-rightA.png -resize 640x480! $outputfile-rightAA.png


#4. Apply the Hue Saturation filter equally to the left and right perspectives (Tools > Color Tools > Hue-Saturation). An example for a color tweak might be Red Hue +36 and Lightness -27:
#------------------> NOT WORKING, need to apply just to RED. How?
#convert $outputfile-leftA.png -modulate 0,-27,36 $outputfile-leftAA.png
#convert $outputfile-rightA.png -modulate 0,-27,36 $outputfile-rightAA.png

#5. Apply a Gamma Levels filter to the left perspective (e.g. Tools > Color Tools > Levels) and raise the Gamma output level to about 12 or so
#------------------>I did a visual comparison between gimp's output and imagemagicks and this is my closest approximation. Maybe there is a better way?
convert $outputfile-leftAA.png -level 0%,100%,1.2 $outputfile-leftAAA.png
convert $outputfile-rightAA.png -level 0%,100%,1.0 $outputfile-rightAAA.png

#6. Apply the Channels Mixer filter to the left perspective (Filters > Colors > Channel Mixer). In the Red Output Channel, change the Red amount to 0.0, change the Green amount to 66.6 and the Blue amount to 33.3. You can play with the Green and Blue settings a bit, e.g. some people might prefer G 70.0 and B 30.0:
#Convert the left perspective to Red (Color Tools > Levels and lower the Green and Blue Output Levels to 0)
#-------------------> I am fairly certain this is correct, but please comment.
convert $outputfile-leftAAA.png -channel r -fx '+u.r*0 + u.g*0.66 + u.b*0.33' -channel g -fx '+u.r*0 + u.g*0 + u.b*0' -channel b -fx '+u.r*0 + u.g*0 + u.b*0' $outputfile-red-left-RGB.png

#7. Convert the right perspective to Cyan (Color Tools > Levels and lower the Red Output Level to 0)
convert $outputfile-rightAAA.png -channel R -fx 0 $outputfile-cyan-right-RGB.png

#8. Layer the new Red and Cyan Layers into one frame (Select All > Copy, then Paste), then in the Layers Panel (Dialog > Layers), select the Screen Mode
convert $outputfile-red-left-RGB.png -channel r -separate "(" +channel $outputfile-cyan-right-RGB.png -separate -delete -3 ")" +channel -combine -depth 8 tmp/$outputfile.png



rm $outputfile-*.png

fonte: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=12543&start=0

Agora estou trabalhando em pequenas modificações para realizar em todas as imagens de uma mesma pasta. Assim que estiver pronto eu posto aqui.

Offline ucastrobr

  • Usuário Ubuntu
  • *
  • Mensagens: 693
  • Usa Ubuntu 11.10 (Oneiric Ocelot)
    • Ver perfil
Re: criação de imagem 3D
« Resposta #6 Online: 31 de Agosto de 2010, 10:22 »
Como funciona este script? Você faz primeiro você faz o trabalho de edição no gimp depois converte para imagemagick, é isso?
Spock – "After a time, you may find that having is not so pleasing a thing, after all, as wanting. It is not logical, but it is often true."
("Depois um de tempo você vai perceber que ter algo pode não ser tão prazeroso quanto deseja-lo. Isto não é lógico, mas frequentemente é verdade.")

Offline Kamei Hyoga

  • Usuário Ubuntu
  • *
  • Mensagens: 1.095
  • Ubuntu 11.04
    • Ver perfil
Re: criação de imagem 3D
« Resposta #7 Online: 31 de Agosto de 2010, 16:19 »
Ele funciona todo via terminal, mas para ficar mais amigável, estou usando o zenity e a notificação do Ubuntu.

Dependências:

-Zenity
-Imagemagick
-Libnotify-bin

Código: [Selecionar]
#!/bin/bash
#Código original por cmisip ( http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=12543&start=0 )
#
#Adaptado por Kamei Hyoga do fórum Ubuntu-br ( http://ubuntuforum-br.org/index.php/topic,71626.0.html )
#
#Dependências:
#-Imagemagick
#-Zenity
#-Libnotify-bin
diretorio=$(zenity --file-selection --directory --title="IMG3d - Selecione o diretório que contém as fotos")
cd $diretorio
mkdir 3D 2>/dev/null

for img in *[.jpg,.jpeg,.JPG,.JPEG,.png,.PNG] ;
do
saida=$img
convert $img -set option:distort:viewport -24-0 -virtual-pixel tile -distort SRT 0 +repage $saida-right
convert $img -set option:distort:viewport +24-0 -virtual-pixel tile -distort SRT 0 +repage $saida-left
convert $saida-left -gravity east -chop 24x0 $saida-leftA
convert $saida-right -chop 24x0 $saida-rightA
convert $saida-leftA -level 0%,100%,1.2 $saida-leftAAA
convert $saida-rightA -level 0%,100%,1.0 $saida-rightAAA
convert $saida-leftAAA -channel r -fx '+u.r*0 + u.g*0.66 + u.b*0.33' -channel g -fx '+u.r*0 + u.g*0 + u.b*0' -channel b -fx '+u.r*0 + u.g*0 + u.b*0' $saida-red-left-RGB
convert $saida-rightAAA -channel R -fx 0 $saida-cyan-right-RGB
convert $saida-leftA -channel r -recolor '0 .66 .33 0 0 0 0 0 0' -gamma 1.2 -separate "(" $saida-rightA -channel gb -separate ")" -channel rgb -combine 3D/$saida

rm $saida-*
done
notify-send -t 100 "IMG3d:" "Todas as imagens convertidas. Aguarde o gerenciador de arquivos abrir" && sleep 3 && gnome-open $diretorio/3D

Ao executar o script, uma janela se abrirá para você selecionar a pasta que contém as imagens que quer converter. Depois de selecionada, o script começa a trabalhar e ao final o Nautilus será aberto no diretório das imagens originais.

Agora resta saber se essas imagens ficaram boas mesmo, porque ainda não fiz meu óculos 3D. Se alguém puder rodar esse script e testar as imagens, eu ficaria agradecido.