简体   繁体   中英

Can the python image module be extended?

Can the python Image module be extended ? Basically its a class I think and I want to have added a numpy array representation of the image.

If I know how to extend it, then I can add all other extensions I wish to add to it too I think, but I don't know how to build up on existing classes.

You "extend" classes by subclassing them, as in

class MiniMath:
    def add(self, a, b):
        return a + b

class MoreMath(MiniMath):
    def sub(self, a, b):
        return a - b

mm = MoreMath()
print mm.add(1, 2) # 3
print mm.sub(1, 2) # -1

I suggest you read the Python tutorial first though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM