Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Summer of code anay293 ML #49

Open
wants to merge 16 commits into
base: best-machine-learning
Choose a base branch
from
4,365 changes: 4,365 additions & 0 deletions Chat_Bot Week4.ipynb

Large diffs are not rendered by default.

881 changes: 881 additions & 0 deletions WEEK 2 YOLO_V4.ipynb

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions Week 3 Image Alignment.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "8f72856b",
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "e21dbb7d",
"metadata": {},
"outputs": [],
"source": [
"def align_image(image):\n",
" \n",
" gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n",
"\n",
" \n",
" sift = cv2.SIFT_create()\n",
"\n",
"\n",
" keypoints, descriptors = sift.detectAndCompute(gray, None)\n",
"\n",
"\n",
" matcher = cv2.BFMatcher()\n",
"\n",
"\n",
" matches = matcher.knnMatch(descriptors, descriptors, k=2)\n",
" \n",
" good_matches = []\n",
" for m, n in matches:\n",
" if m.distance < 0.75 * n.distance:\n",
" good_matches.append(m)\n",
"\n",
" src_points = np.float32([keypoints[m.queryIdx].pt for m in good_matches]).reshape(-1, 1, 2)\n",
" dst_points = np.float32([keypoints[m.trainIdx].pt for m in good_matches]).reshape(-1, 1, 2)\n",
"\n",
"\n",
" M, mask = cv2.findHomography(src_points, dst_points, cv2.RANSAC, 5.0)\n",
"\n",
"\n",
" aligned_image = cv2.warpPerspective(image, M, (image.shape[1], image.shape[0]))\n",
"\n",
" return aligned_image"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "5ad7015f",
"metadata": {},
"outputs": [],
"source": [
"\n",
"image = cv2.imread(\"C:\\\\Users\\\\91740\\\\OneDrive\\\\Desktop\\\\g.jpg\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2361d9d7",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 26,
"id": "81e03c86",
"metadata": {},
"outputs": [],
"source": [
"clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))\n",
"enhanced_image = cv2.cvtColor(image1, cv2.COLOR_BGR2LAB)\n",
"enhanced_image[:, :, 0] = clahe.apply(enhanced_image1[:, :, 0])\n",
"enhanced_image = cv2.cvtColor(enhanced_image1, cv2.COLOR_LAB2BGR)\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "b2a89ab1",
"metadata": {},
"outputs": [],
"source": [
"\n"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "d8c5e61e",
"metadata": {},
"outputs": [],
"source": [
"aligned_image = align_image(enhanced_image)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2e30048",
"metadata": {},
"outputs": [],
"source": [
"cv2.imshow('Aligned Image', aligned_image)\n",
"cv2.waitKey(0)\n",
"cv2.destroyAllWindows()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f9fbe637",
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading