如何水平放置所有三个图像?
我的功能可以将原始图像更改为灰度,负面图像和颜色黄色为蓝色。该代码应该在3个不同的窗口中运行并显示图像。我该如何水平将它们全部放置? 这是代码。
PS我不会使用PIL。
from cImage import *
#there is a code here that that defines the functions, i've cut it out from my
question
def generalTransform(imageFile):
myimagewindow = ImageWin("Image Processing",300,200)
oldimage = FileImage(imageFile)
oldimage.draw(myimagewindow)
newimage = pixelMapper(oldimage,changeYellowToBlue)
newimage.setPosition(oldimage.getWidth()+1,0)
newimage.draw(myimagewindow)
myimagewindow.exitOnClick()
def main():
generalTransform("mickey.gif")
main()
def makenegative(imageFile):
oldImage=FileImage(imageFile)
width=oldImage.getWidth()
height=oldImage.getHeight()
myImageWindow=ImageWin('negativeimage', width*2, height)
oldImage.draw(myImageWindow)
newIm=EmptyImage(width, height)
for row in range(height):
for col in range(width):
oldPixel=oldImage.getPixel(col, row)
newPixel=negativePixel(oldPixel)
newIm.setPixel(col, row, newPixel)
newIm.setPosition(width+1, 0)
newIm.draw(myImageWindow)
myImageWindow.exitOnClick()
def main():
makenegative("mickey.gif")
main()
def makeGrayscale(imageFile):
oldImage=FileImage(imageFile)
width=oldImage.getWidth()
height=oldImage.getHeight()
myImageWindow=ImageWin('grayimage', width*2, height)
oldImage.draw(myImageWindow)
newIm=EmptyImage(width, height)
for row in range(height):
for col in range(width):
oldPixel=oldImage.getPixel(col, row)
newPixel=grayPixel(oldPixel)
newIm.setPixel(col, row, newPixel)
newIm.setPosition(width+1, 0)
newIm.draw(myImageWindow)
myImageWindow.exitOnClick()
def main():
makeGrayscale("mickey.gif")
main()
这是代码的一部分。
I have a function that changes the original image to gray scale, negative image and the color yellow to blue. The code is supposed to run and show the images in 3 different windows. How can I put them all in one, horizontally?
here is the code.
p.s I won't be using PIL.
from cImage import *
#there is a code here that that defines the functions, i've cut it out from my
question
def generalTransform(imageFile):
myimagewindow = ImageWin("Image Processing",300,200)
oldimage = FileImage(imageFile)
oldimage.draw(myimagewindow)
newimage = pixelMapper(oldimage,changeYellowToBlue)
newimage.setPosition(oldimage.getWidth()+1,0)
newimage.draw(myimagewindow)
myimagewindow.exitOnClick()
def main():
generalTransform("mickey.gif")
main()
def makenegative(imageFile):
oldImage=FileImage(imageFile)
width=oldImage.getWidth()
height=oldImage.getHeight()
myImageWindow=ImageWin('negativeimage', width*2, height)
oldImage.draw(myImageWindow)
newIm=EmptyImage(width, height)
for row in range(height):
for col in range(width):
oldPixel=oldImage.getPixel(col, row)
newPixel=negativePixel(oldPixel)
newIm.setPixel(col, row, newPixel)
newIm.setPosition(width+1, 0)
newIm.draw(myImageWindow)
myImageWindow.exitOnClick()
def main():
makenegative("mickey.gif")
main()
def makeGrayscale(imageFile):
oldImage=FileImage(imageFile)
width=oldImage.getWidth()
height=oldImage.getHeight()
myImageWindow=ImageWin('grayimage', width*2, height)
oldImage.draw(myImageWindow)
newIm=EmptyImage(width, height)
for row in range(height):
for col in range(width):
oldPixel=oldImage.getPixel(col, row)
newPixel=grayPixel(oldPixel)
newIm.setPixel(col, row, newPixel)
newIm.setPosition(width+1, 0)
newIm.draw(myImageWindow)
myImageWindow.exitOnClick()
def main():
makeGrayscale("mickey.gif")
main()
This is part of the code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此使用OpenCV库怎么样?
将图像转到灰度之后,您可以将它们连接到水平轴上并彼此相邻显示。
干杯
how about using the OpenCV library for this?
After turning the images to grayscale you can concatenate them on the horizontal axis and display them next to each other.
Cheers