-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correlation notebook and start of formatting of slides
- Loading branch information
Showing
15 changed files
with
469 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"id": "7f71970e-f2f7-48ac-b9f1-507dcc677c5c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from PIL import Image, ImageOps\n", | ||
"import os" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "23c64cd7-1ee0-4eef-b1a8-30e83e8384ef", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def save_img_copy(im_path):\n", | ||
" # Open the image\n", | ||
" img = Image.open(im_path)\n", | ||
"\n", | ||
" # Save the original image as f'{im_path}1'\n", | ||
" base, ext = os.path.splitext(im_path)\n", | ||
" original_save_path = f'{base}1{ext}'\n", | ||
" img.save(original_save_path)\n", | ||
" return img" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 21, | ||
"id": "9f5e11b0-5a4c-4760-98f0-05cabafd33ef", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def resize_image(im_path, resizing_factor):\n", | ||
"\n", | ||
" img = save_img_copy(im_path)\n", | ||
"\n", | ||
" new_size = (int(img.width * resizing_factor), int(img.height * resizing_factor))\n", | ||
"\n", | ||
" if resizing_factor < 1.0:\n", | ||
" # Resize with antialias filter when downsampling\n", | ||
" resized_img = img.resize(new_size, Image.ANTIALIAS)\n", | ||
" else:\n", | ||
" # Just copy the image if upsampling or maintaining size\n", | ||
" resized_img = img.resize(new_size)\n", | ||
"\n", | ||
" # Save the resized image to the original path\n", | ||
" resized_img.save(im_path)\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 22, | ||
"id": "7b151e2c-5d7a-43fb-992c-ac6ad2e85091", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def pad_image(im_path, padding):\n", | ||
"\n", | ||
" img = save_img_copy(im_path)\n", | ||
" \n", | ||
" # Apply the padding (black padding by default)\n", | ||
" padded_img = ImageOps.expand(img, border=padding, fill=(0, 0, 0)) # black fill\n", | ||
" \n", | ||
" # Save the padded image to the specified path\n", | ||
" padded_img.save(im_path)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 23, | ||
"id": "5b517f7e-99ba-4c03-9f5f-acb9cebfe86a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pad_image('registration.png', 100)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 26, | ||
"id": "c1c37b68-a636-4442-a877-a714f169eacc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"resize_image('registration_big.png', 1.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1e3fffdb-1355-4790-940f-56e84abd0f5f", | ||
"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.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters