写真の一部、この例では鼻を拡大したいと思います。
写真の拡大したい部分を選択する機能があります。
def copyAndPaste(picture):
height = getHeight(picture)
width = getWidth(picture)
newPicture = makeEmptyPicture(width, height)
for x in range(width):
for y in range(height):
pxl = getPixel(picture,x,y)
if (x>48 and x<59) and (y>58 and y<71):
newPxl =getPixel(newPicture, #?,#?)
else:
newPxl = getPixel(newPicture, x,y)
color = getColor(pxl)
setColor(newPxl,color)
return newPicture
def d():
f=pickAFile()
picture=makePicture(f)
newPicture = copyAndPaste(picture)
writePictureTo(newPicture, r"D:\FOLDER\0Pic4.jpg")
explore (newPicture)
写真を拡大する機能もあります。
def Enlarge(picture):
height = getHeight(picture)
width = getWidth(picture)
newPicture = makeEmptyPicture(width*2, height*2)
x1=0
for x in range(0,width):
y1=0
for y in range(0,height):
pxl = getPixel(picture,x,y)
newPxl = getPixel(newPicture, x1,y1)
color = getColor(pxl)
setColor(newPxl,color)
y1=y1+2
x1=x1+2
return newPicture
例えば。
から:
に:
私は多くのことを試しましたが、2 つを組み合わせて画像の一部を拡大し、画像の残りの部分をそのままにする方法がわかりません。
これは、結果の画像がどのように見えるかです (ばかげているように)。
プログラムの実行に時間がかかる可能性があるため、小さな画像で練習してきました。この段階では、大きな画像を操作することは実行できません。つまり、結果は大ざっぱですが、少なくとも機能するかどうかは示されます。