Update on Weather API

At the end of last week, I worked more on the Weather shift filter. Since the filters in our app are supposed to have some sort of unusual “glitch” we decided it would be good to not only shift the color temperature of images based on the current temperature, but to do it while also inverting the colors in the entire image.

One of the images with the filter applied (current temperature (47 degrees).

photo-1514846326710-096e4a8035e0.jpg
Before
Screen Shot 2018-12-12 at 2.41.37 PM.png
After

Weather API and Mirror Filter

I worked on taking the API information from Yahoo Weather that Molli started working on and implemented a way to alter the color temperature of an image based on the outside temperature in Boulder.

import urllib
import simplejson as json
import gui

from gui import *


#API WEATHER GLITCH
#Description: This is the starting point for creating our API weather-based glitch.
#It currently uses a yahoo url to grab the current temperature and prints out that value, which we can then use to alter our photographs.
url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22boulder%2C%20co%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
response = urllib.urlopen(url)
data = json.loads(response.read())
print data['query']['results']['channel']['item']['condition']['temp']
print data['query']['results']['channel']['item']['condition']['text']

temperature = data['query']['results']['channel']['item']['condition']['temp']
print int(temperature)
condition = data['query']['results']['channel']['item']['condition']['text']
#print int(condition)

def tempShift():
  temperature = data['query']['results']['channel']['item']['condition']['temp']
  condition = data['query']['results']['channel']['item']['condition']['text']
  
  picture = makePicture(pickAFile())
  
  if temperature > 50:
    for p in getPixels(picture):
      setRed(p,getRed(p)/1.2)
      setGreen(p,getGreen(p)/1.2)
      setBlue(p,getBlue(p)*1.5)
  
  elif temperature < 50: 
    for p in getPixels(picture):
      setRed(p,getRed(p)*1.2)
      setGreen(p,getGreen(p)*1.2)
      setBlue(p,getBlue(p)/1.5)

  #if condition == 'Cloudy':
   # picture.add(cloudImg)
 
  #elif condition == 'Snow':
   # picture.add(snow.png)
    

  explore(picture)


def setUpMediaPaths():
  global filePath
  showInformation("Choose the folder where your media files are")
  filePath = pickAFolder()
  
global cloudImg
def loadClouds():
  global cloudImg
  cloudImg = Icon(filePath + '/clouds.png')
  
  
setUpMediaPaths()  
tempShift()

Screen Shot 2018-12-05 at 2.28.10 PM.png

I also worked on creating the “Section Swap” filter. Currently, this program mirrors the top half of the image into the bottom half. The code is below.

#this function cuts the image horizontally in half and mirrors the top half into the bottom half of the image.


picture = makePicture(pickAFile())

def mirrorUpHalf():
  
  pixels=getPixels(picture)
  target=len(pixels)-1
  for index in range(0,len(pixels)/2):
    pixel1=pixels[index]
    color1=getColor(pixel1)
    pixel2=pixels[target]
    setColor(pixel2,color1)
    target=target-1

mirrorUpHalf()

explore(picture)

Screen Shot 2018-12-05 at 2.27.32 PM.png

 

 

 

 

Anderson W14H2

On Wednesday, I worked on researching some different approaches to manipulating image programs in Python. There are some common effects found in glitch art, one of which is RGB shifting (see image below). Our goal is the have one of our glitch art filters create an RGB shift effect. Additionally, I looked back on some of our previous code from earlier on in the semester when we worked with images to see how our group could continue to use and learn from the skills we started working with.

rgb_split_effect