Home Schedule
Example of looping over pixels and identifying certain color values to change. This example requires the caterpillar image from the media resource and media.py be in the same directory as this code to run the program
    
        import media

        filename = 'caterpillar.jpg'
        
        picture = media.makePicture(filename)
        
        # Open the explorer tool to see information about the picture
        #    DON'T LEAVE THIS IN YOUR PROGRAM IF YOU USE IT!
        #    IT IS FOR TESTING AND PROBLEM SOLVING HELP ONLY!
        media.explore(picture)
        
        # Get all the pixels from the image
        pixels = media.getPixels(picture)
        
        # For each pixel
        for pixel in pixels:
            # Check the color values
            if media.getRed(pixel) >= 200 and media.getGreen(pixel) >= 200 and media.getBlue(pixel) < 10: 
                # If the pixel has a color in the range above, change it to magenta(pink)
                media.setColor(pixel, media.magenta)
        
        media.show(picture)
        
        media.quit()