首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用于图像处理的代码不会产生结果/输出

用于图像处理的代码不会产生结果/输出
EN

Stack Overflow用户
提问于 2019-05-28 02:57:19
回答 1查看 23关注 0票数 0

我正在做一个项目,在这个项目中,我需要使用类和对象来使用PIL在Python中操作图像。

我已经消除了对文件路径的正确格式化,所以代码本身一定有一些东西。

代码语言:javascript
运行
复制
class image_play(object):
    def __init__(self,im_name):
        self.im_name = im_name


    def rgb_to_gray_image(self):
        im = Image.open(self.im_name)
        im = im.convert('LA')
        return im

    # editing pixels of image to white
    def loop_over_image(self):
        im = Image.open(self.im_name)
        width, height = im.size
        # nested loop over all pixels of image
        temp = []
        for i in range(width):
          for j in range(height):
            temp.append((255,255,255)) # append tuple for the RGB values for each pixel

        image_out = Image.new(im.mode,im.size)  #create new image using PIl
        image_out.putdata(temp) #use the temp list to create the image
        return image_out

pic = image_play('test.png')

picGray = pic.rgb_to_gray_image()

picWhite = pic.loop_over_image()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-28 03:16:09

我只是简单地添加了picGray.show()和picWhite.show(),现在我有了可查看的输出。嗯..。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56331199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档