Difference between revisions of "CSC111 JES Program for Image Processing"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- <onlydft> <br /> <source lang="python"> # JES Picture processing # D. Thiebaut # A demo of some of the functions available in JES for manipulating # the pixels of...")
 
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:08, 10 March 2014 (EDT)
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:08, 10 March 2014 (EDT)
 
----
 
----
 +
=Skeleton Program to Get Started With=
 +
<br />
 +
<source lang="python">
 +
# JES Picture processing
 +
# D. Thiebaut
 +
# A demo of some of the functions available in JES for manipulating
 +
# the pixels of an image.
 +
 +
 +
# the image we are playing with
 +
image = None
 +
 +
# changeColor( image ).
 +
# Changes the amount of red, green and blue that is in an image
 +
def changeColor( image ):
 +
  for x in range(0,getWidth(image)):
 +
    for y in range(0,getHeight(image)):
 +
        pixel = getPixel (image, x, y)
 +
        red  = getRed(pixel)
 +
        green = getGreen(pixel)
 +
        blue  = getBlue(pixel)
 +
 
 +
        # the line below replaces the pixel with its original color.  Change
 +
        # the amount of red, green and blue to see some change in the colors
 +
        newColor = makeColor( red, green, blue )
 +
        setColor( pixel, newColor )
 +
  return image
 +
 +
# ================================================================== 
 +
#                            MAIN PROGRAM
 +
# ================================================================== 
 +
file = pickAFile()
 +
image = makePicture( file )
 +
show( image )
 +
 
 +
#image = addBorder( image )
 +
#image = changeColor( image )
 +
#image = makeBlackAndWhite( image )
 +
#image = flipPixelColors( image )
 +
#image  = swapRGBColors( image )
 +
image = addBorder( image, 15 )
 +
repaint( image )
 +
 +
 +
</source>
 +
<br />
 
<onlydft>
 
<onlydft>
 
<br />
 
<br />

Revision as of 09:10, 10 March 2014

--D. Thiebaut (talk) 10:08, 10 March 2014 (EDT)


Skeleton Program to Get Started With


# JES Picture processing
# D. Thiebaut
# A demo of some of the functions available in JES for manipulating 
# the pixels of an image.


# the image we are playing with
image = None

# changeColor( image ).
# Changes the amount of red, green and blue that is in an image
def changeColor( image ):
  for x in range(0,getWidth(image)):
    for y in range(0,getHeight(image)):
        pixel = getPixel (image, x, y)
        red   = getRed(pixel)
        green = getGreen(pixel)
        blue  = getBlue(pixel)
  
        # the line below replaces the pixel with its original color.  Change
        # the amount of red, green and blue to see some change in the colors
        newColor = makeColor( red, green, blue )
        setColor( pixel, newColor )
  return image

# ==================================================================  
#                             MAIN PROGRAM
# ==================================================================  
file = pickAFile()
image = makePicture( file ) 
show( image )
  
#image = addBorder( image )
#image = changeColor( image )
#image = makeBlackAndWhite( image )
#image = flipPixelColors( image )
#image  = swapRGBColors( image )
image = addBorder( image, 15 )
repaint( image )



...