【问题标题】:Interweaving two pictures交织两张图片
【发布时间】:2013-07-20 17:55:53
【问题描述】:

我正在尝试将两张图片交织在一起。

图一图二这个

def interWeave(pic, picture):
  w=getWidth(pic)
  h=getHeight(pic)
  newPic=makeEmptyPicture(w,h)
  for x in range (0,w):
    for y in range (0,h):
      p=getPixel(pic,x,y)
      p2=getPixel(picture,x,y)
      newPxl=getPixel(newPic,x,y)

      if (x>=0 and x<20) or (x>=40 and x<60)or (x>=80 and x<=100):
        color = getColor(p)

      else:
        color=getColor(p2)
        setColor(newPxl, color) 
  return (newPic)

但我明白了:

有人知道我做错了什么吗?

【问题讨论】:

    标签: python jython crop image getpixel


    【解决方案1】:
    if (x>=0 and x<20) or (x>=40 and x<60)or (x>=80 and x<=100):
            color = getColor(p)
    
          else:
            color=getColor(p2)
            setColor(newPxl, color)
    

    如果你的缩进是正确的,你只能在 else 块中 setColor。所以 0~20, 40~60, 80~100 的范围是空白的。

    【讨论】:

      猜你喜欢
      • 2011-10-31
      • 2011-11-04
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多