Skip to content

Commit

Permalink
website and live video added
Browse files Browse the repository at this point in the history
  • Loading branch information
laxmannaik5 committed Mar 12, 2022
1 parent 1206528 commit ab5d732
Show file tree
Hide file tree
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
260 changes: 260 additions & 0 deletions Histogram_Matching/Histogram-Matching-Generation.ipynb
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
}
Loading

0 comments on commit ab5d732

Please sign in to comment.