Giter VIP home page Giter VIP logo

cimage's Introduction

cImage - A simple image processing library for Python

Installation

If using Thonny, go to Tools -> Manage Packages, then enter cs20-image. This should install both the image module, and the Pillow module (so you can use any type of image you'd like).

If you are not using Thonny, copy image.py to your site-packages directory, or just keep it in the same folder as the Python scripts that import it.

Usage

This image library is not going to give you fancy high performance operations on images. It allows you to read in an image and manipulate its pixels. Then you can save the new image to a file, or you can display the image in a window. Thats really about it, but its really all you want to do if you are teaching an introductory computer science course.

Image Types Supported

If you have PIL installed on your system (if you are using Thonny, this was installed along with the image module):

  • jpeg
  • gif
  • tiff
  • png
  • etc.

If you do not have PIL installed then you are stuck with GIF images only.

Example

import image

win = image.ImageWin(480, 640, "Image Processing")
original_image = image.FileImage('lcastle.gif')

width = original_image.get_width()
height = original_image.get_height()
print(width, height)

original_image.draw(win)
my_image = original_image.copy()

for row in range(height):
    for col in range(width):
         v = my_image.get_pixel(col,row)
         v.red = 255 - v.red
         v.green = 255 - v.green
         v.blue = 255 - v.blue
         my_image.set_pixel(col,row,v)

my_image.draw(win)
print(win.get_mouse())
my_image.save('lcastle-inverted.gif')
print(my_image.to_list())
win.exit_on_click()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.