forked from laxmannaik5/SIH
-
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.
- Loading branch information
1 parent
1206528
commit ab5d732
Showing
7,069 changed files
with
327,276 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
Histogram_Matching/.ipynb_checkpoints/Histogram-Matching-Generation-checkpoint.ipynb
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,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
6 changes: 6 additions & 0 deletions
6
Histogram_Matching/.ipynb_checkpoints/Histogram_matching-checkpoint.ipynb
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,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,260 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "67bf3a0b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"from tqdm import tqdm\n", | ||
"import os.path\n", | ||
"from scipy import stats\n", | ||
"import random\n", | ||
"import PIL.ImageDraw as ImageDraw\n", | ||
"import PIL.Image as Image\n", | ||
"import math\n", | ||
"\n", | ||
"\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "0506c3b3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def load_images():\n", | ||
" img_path = './imgs2/'\n", | ||
" imgs = []\n", | ||
" for file in tqdm(os.listdir(img_path)):\n", | ||
" imgs.append(np.array(Image.open(img_path + file)))\n", | ||
" return imgs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"id": "98f561ce", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"100%|███████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 200.56it/s]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"img = load_images()[0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"id": "dae45f4b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def generate_histogram(img):\n", | ||
" \"\"\"\n", | ||
" @params: img: can be a grayscale or color image. We calculate the Normalized histogram of this image.\n", | ||
" @params: do_print: if or not print the result histogram\n", | ||
" @return: will return both histogram and the grayscale image \n", | ||
" \"\"\"\n", | ||
" if len(img.shape) == 3: # img is colorful, so we convert it to grayscale\n", | ||
" gr_img = np.mean(img, axis=-1)\n", | ||
" else:\n", | ||
" gr_img = img\n", | ||
" '''now we calc grayscale histogram'''\n", | ||
" gr_hist = np.zeros([256])\n", | ||
"\n", | ||
" for x_pixel in range(gr_img.shape[0]):\n", | ||
" for y_pixel in range(gr_img.shape[1]):\n", | ||
" pixel_value = int(gr_img[x_pixel, y_pixel])\n", | ||
" gr_hist[pixel_value] += 1\n", | ||
" \n", | ||
" '''normalizing the Histogram'''\n", | ||
" ##gr_hist /= (gr_img.shape[0] * gr_img.shape[1])\n", | ||
" return gr_hist, gr_img" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "877261d0", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"256" | ||
] | ||
}, | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"len(generate_histogram(img)[0])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"id": "22e3f908", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pixel_count1 = generate_histogram(img)[0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3aa0d772", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"intensity = list(range(0,256))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "740b5dc7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "17745c58", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pd.DataFrame(pixel_count1, columns = ['pixel_count1'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"id": "9421f9cb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pixel_count2 = generate_histogram(img)[0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d71124af", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pixel_count2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8190c2dc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pd.DataFrame(pixel_count2, columns = ['pixel_count2'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fa177a8f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pixel_count1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "63fa4d41", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"generate_histogram(img)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"id": "cdfd36d6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"r = np.corrcoef(pixel_count1, pixel_count2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"id": "60574196", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"array([[ 1. , -0.07814372],\n", | ||
" [-0.07814372, 1. ]])" | ||
] | ||
}, | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"r" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bb1ddb65", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.8.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.