{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Lab 06: Image Filters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from PIL import Image\n",
"from io import BytesIO\n",
"import requests"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Activity 1: Gradient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def make_gradient_image(width, height, source, target):\n",
" ''' Given the width and height of the target image, this function \n",
" produces a gradient image that goes from source color to target color.\n",
" ''' \n",
" return None"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Testing \n",
"\n",
"Use the `make_gradient_image` function to create two different gradients and `display` them here."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Reflection\n",
"\n",
"1. Describe how you implemented the `make_gradient_image`. In particular, describe the overall control flow in the function and the computation you performed to determine the color at each pixel.\n",
"\n",
" Response Here\n",
" \n",
"\n",
"2. Currently, the `make_gradient_image` function produces a vertical gradient. How would you instead produce a horizontal gradient?\n",
"\n",
" Response Here\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Activity 2: Blend"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def blend_images(image1, image2, weight):\n",
" ''' Blend the two given images using the specified weight:\n",
" \n",
" new_pixel = pixel1*weight + pixel2*(1 - weight)\n",
" '''\n",
" return None"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Testing\n",
"\n",
"Use the `blend_images` function to blend two different pairs of images and `display` them here."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Reflection\n",
"\n",
"1. Describe how you implemented the `blend_images`. In particular, describe the overall control flow in the function and the computation you performed to determine the color at each pixel.\n",
"\n",
" Response Here\n",
" \n",
"\n",
"2. What happens if the two images don't have the same dimensions? What could you do to ensure that the blend operation always works even if the images are different sizes?\n",
"\n",
" Response Here\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python3",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}