0

我无法将我的 CGI 图片和小插图个人资料图像放在一起制作小插图图片,其中图片边缘的图片稍微较暗,而不会影响其他任何地方的图像,到目前为止,我认为是是的,但我的图片在中间显示为暗,而不是正常显示图像,但边缘颜色稍暗。

这是我目前拥有的:

def main(): 
inputPic = makePicture(pickAFile()) 
vignette = makePicture(pickAFile())
 addVignette(inputPic, vignette) 
def addVignette(inputPic, vignette): 
if getWidth(inputPic) == getWidth(vignette) and getHeight(inputPic) == getHeight(vignette):
  explore(inputPic)
  explore(vignette)
  px1 = getPixels(inputPic)
  px2 = getPixels(vignette) 
 for px in getPixels(inputPic): 
 x = getX(px)
  y = getY(px)
  px2 = getPixelAt(vignette, x, y)
  x2 = getX(px2)
  y2 = getY(px2)
  r1 = getRed(px)
  r2 = getRed(px2)
  g1 = getGreen(px)
  g2 = getGreen(px2)
  b1 = getBlue(px)
  b2 = getBlue(px2)
  newR = (r1-r2+104)
  newG = (g1-g2+88)
  newB = (b1-b2+48)
  newC = makeColor(newR, newG, newB)
  setColor(px, newC)
 explore(inputPic)
 folder = pickAFolder()
 filename = requestString("enter file name: ")
 path = folder+filename+".jpg" 
 writePictureTo(inputPic, path)

http://i.stack.imgur.com/PqW7K.jpg

图片1是图像需要的

http://i.stack.imgur.com/PtS4U.jpg

图 2 是我在编码结束时得到的图像

任何帮助我朝着正确的方向前进将不胜感激

4

1 回答 1

0

在前 3 次完全出错之后,我在我的小朋友模块操作员的帮助下解决了这个问题。

def addVignette(inputPic, vignette):
  # Create empty canvas
  canvas = makeEmptyPicture(getWidth(inputPic), getHeight(inputPic))

  for x in range(0, getWidth(inputPic)):
    for y in range(0, getHeight(inputPic)):
      px = getPixel(canvas, x, y)
      inputPixel = getPixel(inputPic, x, y)
      vignettePixel = getPixel(vignette, x, y)

      # Make a new color from those values
      newColor = getNewColorValues(inputPixel, vignettePixel)

      # Assign this new color to the current pixel of the input image
      setColor(px, newColor)

  explore(canvas)

def getNewColorValues(inputPixel, vignettePixel):

  inputRed = getRed(inputPixel)
  vignetteRed = getRed(vignettePixel)
  inputGreen = getGreen(inputPixel)
  vignetteGreen = getGreen(vignettePixel)
  inputBlue = getBlue(inputPixel)
  vignetteBlue = getBlue(vignettePixel)

  newR = inputRed - (255 % vignetteRed) / 3
  newG = inputGreen - (255 % vignetteGreen) / 3
  newB = inputBlue - (255 % vignetteBlue) / 3

  newC = makeColor(newR, newG, newB)
  return newC
于 2014-09-03T11:20:22.423 回答