A Python Program For Image Model

Python Trackbacks (0) Comments (2)   
class pixel:
    width = 2
    height = 2
    pixel = [[0,0],[0,0]]
    def __init__(self):
        pass
    def set_width(self,x):
        if (x >= self.width):
            for list in self.pixel:
                for i in range(x - self.width):
                    list.append(0)
        self.width = x
    def set_height(self,y):
        if (y >= self.height):
            temp = []
            for i in range(self.width):
                temp.append(0)
            for i in range(y-self.height):
                self.pixel.append(temp)
        self.height = y
    def get_width(self):
        return self.width
    def get_height(self):
        return self.height
    def set_pixel(self,x,y,value):
        self.pixel[x][y] = value
    def show_pixel(self):
        print self.pixel
if __name__ == "__main__":
    p = pixel()
    p.set_width(5)
    p.set_height(5)
    for i in range(4):
        for j in range(4):
            p.set_pixel(i+1,j+1,i+j)
    print p.pixel

Congratulations!

General Trackbacks (0) Add comment   
If you can read this post, it means that the registration process was successful and that you can start blogging
Design by N.Design Studio
Powered by Lifetype. Template adapted by Russian Lifetype