SHARE
TWEET

Manipulando imagem(2c)

DomMisterSoja Sep 14th, 2018 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. arquivo=open('vitor.pgm','r')
  2. linha=''
  3. l1 = arquivo.readline()
  4. l2 = arquivo.readline()
  5. l3 = arquivo.readline()
  6. for i in arquivo:
  7.     i = i.split(' ')
  8.     for a in i:
  9.         if(a=='\n'):
  10.             linha+= f' {a}'
  11.         else:
  12.             a=int(a)
  13.             b=255-a
  14.             b=str(b)
  15.             linha+= f' {b}'
  16. print(linha)
  17. arquivo.close()
  18.  
  19. arquivo2 = open('vitor17.pgm','w')
  20. arquivo2.write(l1)
  21. arquivo2.write(l2)
  22. arquivo2.write(l3)
  23.  
  24. arquivo2.writelines(linha)
  25.  
  26. arquivo2.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top