Welcome to Inkbunny...
Allowed ratings
To view member-only content, create an account. ( Hide )
Jay Moose
« older newer »
Jay1743
Jay1743's Gallery (83)

Image filter for color manipulation (Pretty sunset!)

It Gets Better: Prequel

Medium (920px wide max)
Wide - use max window width - scroll to see page ⇅
Fit all of image in window
set default image size: small | medium | wide
Download (new tab)
page 1
page 2
by Jay1743
So I was playing around with Python's Image Manipulation Library (PIL) and I wrote my own image filter. It allows the user to transpose the red, green, and blue values in an image in any way they want.

Here's a picture I took of the sun setting over the Mississippi near Baton Rouge. I used the filter to transpose all the red and blue values - so the light blue sky becomes a light red sky, and the deep red sunset becomes an alien blue sunset. (For what it's worth, I'm pretty sure a blue sunset like this is a physical impossibility. Rayleigh scattering doesn't work that way)

Using the filter is easy. Install PIL and run this program:


#!/usr/bin/python

import Image, sys

correctusage = "img <input_filename> <output_format>\noutput_format = RBG, BRG, BGR, GRB, or GBR"

if (len(sys.argv) != 3):
    print "ERROR - incorrect usage"
    print correctusage
    sys.exit(1)

dotpos = sys.argv[1].rfind(".")
basename = sys.argv[1][0:dotpos]
extension = sys.argv[1][dotpos+1:]

infile = Image.open("sunset.jpg")
r, g, b = infile.split()

if (sys.argv[2].upper()=="RBG"):
    outpic = Image.merge("RGB", (r, b, g))
elif (sys.argv[2].upper()=="BRG"):
    outpic = Image.merge("RGB", (b, r, g))
elif (sys.argv[2].upper()=="BGR"):
    outpic = Image.merge("RGB", (b, g, r))
elif (sys.argv[2].upper()=="GRB"):
    outpic = Image.merge("RGB", (g, r, b))
elif (sys.argv[2].upper()=="GBR"):
    outpic = Image.merge("RGB", (g, b, r))
else:
    print "ERROR - Unrecognized output format."
    print correctusage
    sys.exit(2)

outpic.save(basename + "_mod." + extension)



Keywords
color 11,897, tool 694, filter 73
Details
Type: Picture Series
Published: 14 years, 5 months ago
Rating: General

MD5 Hash for Page 1... Show Find Identical Posts [?]
Stats
126 views
3 favorites
4 comments

BBCode Tags Show [?]
 
theuncalledfor
14 years, 5 months ago
OMG IZ DAT A NUK?
Jay1743
14 years, 5 months ago
I had the same thought. This interview to mind.
DorkyWolf
14 years, 5 months ago
Ahhh... too much technical wording for me... >.< Im not good with this stuff anymore!! lol, and that looks pretty sweet!
Jay1743
14 years, 5 months ago
Thanks, Dorky :)
New Comment:
Move reply box to top
Log in or create an account to comment.