Skip to content

Commit

Permalink
adding lab poster
Browse files Browse the repository at this point in the history
  • Loading branch information
senr1 committed Nov 25, 2024
1 parent bbd0ae6 commit e983dcc
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 5 deletions.
Binary file modified .DS_Store
Binary file not shown.
174 changes: 174 additions & 0 deletions .ipynb_checkpoints/Untitled-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 16,
"id": "83bb7943",
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np\n",
"\n",
"def selective_blur(image_path, outputPath, blur_strength=10, focus_area_fraction=1):\n",
" # Load the image\n",
" image = cv2.imread(image_path)\n",
" \n",
" if image is None:\n",
" print(\"Error loading image\")\n",
" return\n",
" \n",
" # Ensure blur_strength is an odd number\n",
" if blur_strength % 2 == 0:\n",
" blur_strength += 1\n",
"\n",
" # Dimensions of the image\n",
" height, width = image.shape[:2]\n",
" \n",
" # Calculate the size of the central area to keep in focus\n",
" central_width = int(width * focus_area_fraction)\n",
" central_height = int(height * focus_area_fraction)\n",
" \n",
" # Calculate the starting point of the central region\n",
" start_x = (width - central_width) // 2\n",
" start_y = (height - central_height) // 2\n",
" \n",
" # Region of Interest (ROI) in the center of the image\n",
" center_region = image[start_y:start_y+central_height, start_x:start_x+central_width]\n",
" \n",
" # Apply Gaussian Blur to the center region\n",
" blurred_center = cv2.GaussianBlur(center_region, (blur_strength, blur_strength), 0)\n",
" \n",
" # Replace the center region of the original image with blurred version\n",
" image[start_y:start_y+central_height, start_x:start_x+central_width] = blurred_center\n",
" # Display the original and modified images\n",
" #cv2.imshow(\"Blurred Center Image\", image)\n",
" #cv2.waitKey(0)\n",
" #cv2.destroyAllWindows()\n",
" \n",
" # Save the result if desired\n",
" cv2.imwrite(outputPath, image)\n",
"\n",
"# Usage\n",
"inputPath = \"/Users/rai/Documents/GitHub/html5up-dimension/images/bg_original.jpg\"\n",
"outputPath = \"/Users/rai/Documents/GitHub/html5up-dimension/images/bg.jpg\"\n",
"image = selective_blur(inputPath, outputPath)\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "470ebab4",
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np\n",
"\n",
"def radial_gradient_blur(image_path, outputPath):\n",
" # Load the image\n",
" image = cv2.imread(image_path)\n",
" \n",
" if image is None:\n",
" print(\"Error loading image\")\n",
" return\n",
"\n",
" # Dimensions of the image\n",
" height, width = image.shape[:2]\n",
" center_x, center_y = width // 2, height // 2\n",
"\n",
" # Create an empty output image\n",
" blurred_image = np.zeros_like(image)\n",
"\n",
" # Maximum blur radius\n",
" max_radius = int(np.sqrt(center_x**2 + center_y**2))\n",
"\n",
" # Create radial blur effect\n",
" for y in range(height):\n",
" for x in range(width):\n",
" # Calculate distance to the center\n",
" distance = int(np.sqrt((center_x - x)**2 + (center_y - y)**2))\n",
" blur_amount = int(20 * (distance / max_radius)) # Change '20' to adjust max blur strength\n",
"\n",
" # Ensure blur_amount is odd and at least 1\n",
" blur_amount = max(1, blur_amount)\n",
" if blur_amount % 2 == 0:\n",
" blur_amount += 1\n",
"\n",
" # Blur the pixel based on distance to the center\n",
" region = image[max(0, y - blur_amount // 2):min(height, y + blur_amount // 2 + 1),\n",
" max(0, x - blur_amount // 2):min(width, x + blur_amount // 2 + 1)]\n",
" blurred_pixel = cv2.GaussianBlur(region, (blur_amount, blur_amount), 0)\n",
" blurred_image[y, x] = blurred_pixel[blur_amount // 2, blur_amount // 2]\n",
"\n",
" # Display the original and modified images\n",
" cv2.imshow(\"Original Image\", image)\n",
" #cv2.imshow(\"Radially Blurred Image\", blurred_image)\n",
" #cv2.waitKey(0)\n",
" #cv2.destroyAllWindows()\n",
"\n",
" # Save the result if desired\n",
" cv2.imwrite(outputPath, image)\n",
"\n",
"# Usage\n",
"inputPath = \"/Users/rai/Documents/GitHub/html5up-dimension/images/bg_original.jpg\"\n",
"outputPath = \"/Users/rai/Documents/GitHub/html5up-dimension/images/bg.jpg\"\n",
"image = radial_gradient_blur(inputPath,outputPath)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6df86bb8",
"metadata": {},
"outputs": [],
"source": [
"from PIL import Image\n",
"\n",
"inputPath = \"/Users/rai/Documents/GitHub/rs3966.github.io/images/theLabPoster.jpg\"\n",
"outputPath = \"/Users/rai/Documents/GitHub/rs3966.github.io/images/theLabPoster_sized.jpg\"\n",
"fraction = 0.5\n",
"# Open an image file\n",
"with Image.open(inputPath) as img:\n",
" # Calculate the new size, 75% of the original size\n",
" new_width = int(img.width * fraction)\n",
" new_height = int(img.height * fraction)\n",
" \n",
" # Resize the image\n",
" resized_img = img.resize((new_width, new_height), Image.ANTIALIAS)\n",
" \n",
" # Save the resized image\n",
" resized_img.save(outputPath)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4fdcdb95",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"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.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
8 changes: 4 additions & 4 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 4,
"id": "6df86bb8",
"metadata": {},
"outputs": [],
"source": [
"from PIL import Image\n",
"\n",
"inputPath = \"/Users/rai/Documents/GitHub/html5up-dimension/images/improv.png\"\n",
"outputPath = \"/Users/rai/Documents/GitHub/html5up-dimension/images/improv_sized.png\"\n",
"fraction = 1\n",
"inputPath = \"/Users/rai/Documents/GitHub/rs3966.github.io/images/theLabPoster.jpg\"\n",
"outputPath = \"/Users/rai/Documents/GitHub/rs3966.github.io/images/theLabPoster_sized.jpg\"\n",
"fraction = 0.5\n",
"# Open an image file\n",
"with Image.open(inputPath) as img:\n",
" # Calculate the new size, 75% of the original size\n",
Expand Down
Binary file modified images/.DS_Store
Binary file not shown.
Binary file added images/theLabPoster.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/theLabPoster_sized.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ <h3>From Stage to Science</h3>
</a>, Laugh Index Theater (DC), and <a href="https://magnettheater.com/people/rajyashree-sen/" target="_blank">
Magnet Theater (New York)</a>. Currently, I study at the Conservatory in
Second City and produce ‘The Lab,’ an indie improv show inspired by scientist interviews. </p>
<h3>The Lab: Bridging Community and Science Through Improv Comedy </h3> <h4>A Public Engagement Project</h4>
<h3>The Lab: Bridging Community and Science Through Improv Comedy </h3>
<h4>A Public Engagement Project</h4>
<img src="images/theLabPoster_sized.jpg" alt="">
<br> <br>
<p> The Lab' is a quarterly improv-comedy show offering science-inspired performances, each driven by an interview
with a neuroscientist. I founded the group with funding from Columbia University's Public Engagement Program,
and developed it in partnership with the artistic community at Magnet Theater in New York City, where I
Expand Down

0 comments on commit e983dcc

Please sign in to comment.