如何在JES中创建图片拼贴?

时间:2017-03-27 00:49:51

标签: copy jes

I've been trying to create a collage of images in JES but when I call createCopy2(), they pop up separately and only one has gone through the change I've told it to(the pic that turns into sepia colored). How do I get them to come up on the same page in the spacing that I want them too?? thanks!!

#def createCollage():
#blurCopy(pic1)
#laplacian(pic2)
#sepiaTint(pic3)
#sharpen(pic4)

def copy(source, target, targetX, targetY):
 for sourceX in range(0, getWidth(source)):
    for sourceY in range(0, getHeight(source)):
      px = getPixel(source, sourceX, sourceY)
      tx = getPixel(target, targetX, targetY)
      setColor(tx, getColor(px))
      targetY = targetY + 1
    targetX = targetX + 1

def blurCopy(src):
  target = copyAPicture(src)
  for x in range(1, getWidth(src)-1):
    for y in range(1, getHeight(src)-1):
      top = getPixel(src, x, y-1)
      left = getPixel(src, x-1, y)
      bottom = getPixel(src, x, y+1)
      right = getPixel(src, x+1, y)
      center = getPixel(target, x, y)
      newRed = (getRed(top)+getRed(left)+getRed(bottom)+getRed(right)+getRed(center))/5
      newGreen = (getGreen(top)+getGreen(left)+getGreen(bottom)+getGreen(right)+getGreen(center))/5
      newBlue = (getBlue(top)+getBlue(left)+getBlue(bottom)+getBlue(right)+getBlue(center))/5
      setColor(center, makeColor(newRed, newGreen, newBlue))
  return target

当我单独调用这些照片时,它们会被过滤但是当我调用createCopy2()时它们不会...

def addPictures(first,second):
  height= getHeight(first)
  width= getWidth(first)
  canvas= makeEmptyPicture(width,height)
  for x in range(1, width-1):
    for y in range(1,height-1):
      pix1= getPixel(first,x,y)
      pix2= getPixel(second,x,y)
      pix3= getPixel(canvas,x,y)
      red1= getRed(pix1)
      green1= getGreen(pix1)
      blue1= getBlue(pix1)
      red2 = getRed(pix2)
      green2= getGreen(pix2)
      blue2= getBlue(pix2)
      newRed= red1+red2
      newGreen= green1+green2
      newBlue= blue1+blue2
      setColor(pix3, makeColor(newRed, newGreen, newBlue))
  return(canvas)

def laplacian(picture):
  target = copyAPicture(picture)
  for x in range(1, getWidth(picture)-1):
    for y in range(1, getHeight(picture)-1):
      top = getPixel(picture, x, y-1)
      topleft= getPixel(picture, x-1, y-1)
      topright= getPixel(picture, x+1, y-1)
      left = getPixel(picture, x-1, y)
      bottom = getPixel(picture, x, y-1)
      bottomleft= getPixel(picture, x-1, y+1)
      bottomright= getPixel(picture, x+1, y+1)
      right = getPixel(picture, x-1, y)
      centertarget= getPixel(target, x,y)
      center = getPixel(picture, x, y)
      newRed = (getRed(center)*8)-(getRed(top)+getRed(left)+ getRed(right)+ getRed(bottom) + getRed(topleft)+getRed(topright)+ getRed(bottomleft)+getRed(bottomright))
      newGreen = (getGreen(center)*8)-(getGreen(top)+getGreen(left)+getGreen(bottom)+getGreen(right)+ getGreen(topleft)+getGreen(topright)+ getGreen(bottomleft)+getGreen(bottomright))
      newBlue = (getBlue(center)*8)-(getBlue(top)+getBlue(left)+getBlue(bottom)+getBlue(right)+ getBlue(topleft)+getBlue(topright)+ getBlue(bottomleft)+getBlue(bottomright))
      setColor(centertarget, makeColor(newRed, newGreen, newBlue))
  return target

def sharpen(picture):
  edges= laplacian(picture)
  adding=addPictures(edges, picture)
  return adding

def grayscaleNew(pic):
  for p in getPixels(pic):
    newRed= getRed(p)*.299
    newGreen= getGreen(p)*.587
    newBlue= getBlue(p)*.114
    luminance= newRed+newGreen+newBlue
    setColor(p, makeColor(luminance, luminance, luminance))  

def sepiaTint(pic):
  grayscaleNew(pic)
  for p in getPixels(pic):
    red= getRed(p)
    blue= getBlue(p)
    if (red< 63):
      red = red*1.1
      blue= blue*.9
    if (red> 62 and red< 192):
      red= red*1.15
      blue=blue*.85
    if (red> 191):
      red= red*1.08
      if (red> 255):
        red= 255
      blue= blue*.93
    setBlue(p, blue)
    setRed(p, red)
  return pic

def copyInset(source, target, startX, startY, finX, finY):
  for targetX in range(startX, finX):
    for targetY in range(startY, finY):
      color = getColor(getPixel(source, startX, startY))
      setColor(getPixel(source, finX, finY), color)
      startY = startY +1
    startX = startX+ 1
  explore(target)
  return target    

def copyInset2(source, target, targX, targY):
  targetX= targX
  for sourceX in range(0, getWidth(source)):
    targetY = targY
    for sourceY in range(0, getHeight(source)):
      px= getPixel(source, sourceX, sourceY)
      tx = getPixel(target, targetX, targetY)
      setColor(tx, getColor(px))
      targetY = targetY +1
    targetX = targetX +1
  return target

def createCopy3():
  pic1 = makePicture("glacierfacial.jpg")
  pic2 = makePicture("yukon.jpg")
  pic3 = makePicture("meltingglacier.jpg")
  pic4 = makePicture("glacierlake.jpeg")
  canvas = makeEmptyPicture(800,600)
  sharpen(pic1)
  copyInset2(pic1,canvas, 0, getHeight(canvas) -getHeight(pic1)-5)
  laplacian(pic2)
  copyInset2(pic2,canvas, 0, getHeight(canvas) -getHeight(pic2)-5) 
  sepiaTint(pic3)
  copyInset2(pic3,canvas, 0, getHeight(canvas) -getHeight(pic3)-5)
  blurCopy(pic4)
  copyInset2(pic4,canvas, 0, getHeight(canvas) -getHeight(pic4)-5)
  explore(canvas)
  return canvas

这是我一直试图使用的副本

def copyInset(source, target, startX, startY, finX, finY):
  for targetX in range(startX, finX):
    for targetY in range(startY, finY):
      color = getColor(getPixel(source, startX, startY))
      setColor(getPixel(source, finX, finY), color)
      startY = startY +1
    startX = startX+ 1
  explore(target)
  return target   

我一直在使用这个,但刚创建了createCopy3()

def createCopy2():
  pic1 = makePicture("glacierfacial.jpg")
  pic2 = makePicture("yukon.jpg")
  pic3 = makePicture("meltingglacier.jpg")
  pic4 = makePicture("glacierlake.jpeg")
  canvas = makeEmptyPicture(800,600)
  sharpen(pic1)
  copyInset(canvas, pic1, 0,0,395,295)
  laplacian(pic2)
  copyInset(canvas, pic2, 0,305,405,599)  
  sepiaTint(pic3)
  copyInset(canvas, pic3, 405,0,799,295)
  blurCopy(pic4)
  copyInset(canvas, pic4, 405,305,799,599)
  show(canvas)
  return canvas

0 个答案:

没有答案