• Save
Python & Perl: PIL & PyGame by Example: Dot Circles, Texts, Tile Ornaments, Image Grayscaling & Binarization, Random Circles
Upcoming SlideShare
Loading in...5
×
 

Python & Perl: PIL & PyGame by Example: Dot Circles, Texts, Tile Ornaments, Image Grayscaling & Binarization, Random Circles

on

  • 1,193 views

 

Statistics

Views

Total Views
1,193
Views on SlideShare
855
Embed Views
338

Actions

Likes
1
Downloads
0
Comments
0

38 Embeds 338

http://vkedco.blogspot.com 153
http://www.vkedco.blogspot.com 77
http://reader.aol.com 12
http://vkedco.blogspot.in 10
http://vkedco.blogspot.de 9
http://vkedco.blogspot.mx 5
http://vkedco.blogspot.tw 4
http://vkedco.blogspot.ru 4
http://vkedco.blogspot.it 4
http://vkedco.blogspot.sk 4
http://vkedco.blogspot.co.uk 3
http://vkedco.blogspot.sg 3
http://vkedco.blogspot.com.ar 3
http://www.vkedco.blogspot.in 3
http://vkedco.blogspot.fr 3
http://www.vkedco.blogspot.nl 3
http://vkedco.blogspot.co.il 3
http://vkedco.blogspot.com.br 3
http://vkedco.blogspot.ca 3
http://vkedco.blogspot.kr 3
http://www.vkedco.blogspot.tw 2
http://vkedco.blogspot.ch 2
http://vkedco.blogspot.nl 2
http://translate.googleusercontent.com 2
http://www.vkedco.blogspot.fr 2
http://vkedco.blogspot.be 2
http://www.vkedco.blogspot.ca 2
http://vkedco.blogspot.pt 2
http://vkedco.blogspot.gr 1
http://vkedco.blogspot.ro 1
http://www.vkedco.blogspot.co.uk 1
http://vkedco.blogspot.co.nz 1
http://vkedco.blogspot.com.es 1
http://www.vkedco.blogspot.ro 1
http://vkedco.blogspot.jp 1
http://vkedco.blogspot.co.at 1
http://vkedco.blogspot.com.au 1
http://vkedco.blogspot.fi 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Python & Perl: PIL & PyGame by Example: Dot Circles, Texts, Tile Ornaments, Image Grayscaling & Binarization, Random Circles Python & Perl: PIL & PyGame by Example: Dot Circles, Texts, Tile Ornaments, Image Grayscaling & Binarization, Random Circles Presentation Transcript

  • Python & Perl PIL & PyGame Basics By Example Dot Circles, Texts, Tile Ornaments, Image Grayscaling & Binarization, Random Circles Vladimir Kulyukinwww.youtube.com/vkedco www.vkedco.blogspot.com
  • Outline ● Comments on Final Project Proposals ● PIL Examples – Drawing dot circles – Drawing text – Generating tile ornaments – RGB to Grayscale to Binary ● PyGame Examples – Drawing Random Circleswww.youtube.com/vkedco www.vkedco.blogspot.com
  • PIL Exampleswww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Dot Circle Write a PIL program that creates an RGB image of a given background and size, draws a circle on it of a given color, and saves it in a file.www.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Dot Circlewww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Dot Circle def make_dot_circle_image(img_fp, img_size=100, radius=30, img_background=white, dot_color=(0, 0, 255)): img = Image.new(RGB, (img_size, img_size), img_background) center_x = center_y = img_size / 2 # make sure circle can fit in image if radius > (img_size/2 - 1): radius = img_size/2 - 1 # draw 360 dots for angle in range(361): theta = radians(angle) x = center_x + radius * cos(theta) y = center_y + radius * sin(theta) img.putpixel((int(x), int(y)), dot_color) # save img object into image_fp and delete img.save(img_fp) del img source code is herewww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Drawn Text Write a PIL program that creates an RGB image of a given background and size, draws a text on it and saves the image into a file.www.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Drawn Text source code is herewww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Run-Length Tile Ornaments Write a PIL program that uses run-length coding to create RGB images with tile ornaments. source code is herewww.youtube.com/vkedco www.vkedco.blogspot.com
  • Run-Length Encoding ● Run-Length Encoding is a form of data compression ● It is applicable whenever data contains sequences (aka runs) of the same value which can be encoded in terms of the value and the number of times that value occurs in a run ● Example: 000000000111111100000 can be represented is (0, 9), (1, 7), (0, 5)www.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Run-Length Tile Ornamentswww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Run-Length Tile Ornamentswww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Run-Length Tile Ornamentswww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Luminosity & Binarization Write a PIL program that converts RGB images to grayscale and binarizes them. source code is herewww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Luminosity & Binarization RGB Grayscale Binarywww.youtube.com/vkedco www.vkedco.blogspot.com
  • PyGame Exampleswww.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Random Circles Write a PyGame program that draws circles of random colors by capturing events inside (e.g., mouse moves).www.youtube.com/vkedco www.vkedco.blogspot.com
  • Exercise: Random Circles source code is herewww.youtube.com/vkedco www.vkedco.blogspot.com
  • Reading & References ● www.python.org ● http://en.wikipedia.org/wiki/Duck_typing ● http://www.pythonware.comwww.youtube.com/vkedco www.vkedco.blogspot.com