Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Analysis of CardiActivites Dataset #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Advance/opencv-inpainting/examples/example01.png
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 Advance/opencv-inpainting/examples/example02.png
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 Advance/opencv-inpainting/examples/example03.png
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 Advance/opencv-inpainting/examples/mask01.png
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 Advance/opencv-inpainting/examples/mask02.png
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 Advance/opencv-inpainting/examples/mask03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
286 changes: 286 additions & 0 deletions Advance/opencv-inpainting/opencv_inpainting.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# USAGE\n",
"# python opencv_inpainting.py --image examples/example01.png --mask examples/mask01.png\n",
"\n",
"# import the necessary packages\n",
"import argparse\n",
"import cv2"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"usage: ipykernel_launcher.py [-h] -i IMAGE -m MASK [-a {telea,ns}] [-r RADIUS]\n",
"ipykernel_launcher.py: error: the following arguments are required: -i/--image, -m/--mask\n"
]
},
{
"ename": "SystemExit",
"evalue": "2",
"output_type": "error",
"traceback": [
"An exception has occurred, use %tb to see the full traceback.\n",
"\u001b[1;31mSystemExit\u001b[0m\u001b[1;31m:\u001b[0m 2\n"
]
}
],
"source": [
"# construct the argument parser and parse the arguments\n",
"ap = argparse.ArgumentParser()\n",
"ap.add_argument(\"-i\", \"--image\", type=str, required=True,\n",
"\thelp=\"path input image on which we'll perform inpainting\")\n",
"ap.add_argument(\"-m\", \"--mask\", type=str, required=True,\n",
"\thelp=\"path input mask which corresponds to damaged areas\")\n",
"ap.add_argument(\"-a\", \"--method\", type=str, default=\"telea\",\n",
"\tchoices=[\"telea\", \"ns\"],\n",
"\thelp=\"inpainting algorithm to use\")\n",
"ap.add_argument(\"-r\", \"--radius\", type=int, default=3,\n",
"\thelp=\"inpainting radius\")\n",
"args = vars(ap.parse_args())\n",
"\n",
"# initialize the inpainting algorithm to be the Telea et al. method\n",
"flags = cv2.INPAINT_TELEA\n",
"\n",
"# check to see if we should be using the Navier-Stokes (i.e.,Bertalmio\n",
"# et al.) method for inpainting\n",
"if args[\"method\"] == \"ns\":\n",
"\tflags = cv2.INPAINT_NS\n",
" \n",
"# load the (1) input image (i.e., the image we're going to perform\n",
"# inpainting on) and (2) the mask which should have the same input\n",
"# dimensions as the input image -- zero pixels correspond to areas\n",
"# that *will not* be inpainted while non-zero pixels correspond to\n",
"# \"damaged\" areas that inpainting will try to correct\n",
"image = cv2.imread(args[\"image\"])\n",
"mask = cv2.imread(args[\"mask\"])\n",
"mask = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)\n",
"\n",
"# perform inpainting using OpenCV\n",
"output = cv2.inpaint(image, mask, args[\"radius\"], flags=flags)\n",
"\n",
"# show the original input image, mask, and output image after\n",
"# applying inpainting\n",
"cv2.imshow(\"Image\", image)\n",
"cv2.imshow(\"Mask\", mask)\n",
"cv2.imshow(\"Output\", output)\n",
"cv2.waitKey(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"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.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
46 changes: 46 additions & 0 deletions Advance/opencv-inpainting/opencv_inpainting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# USAGE
# python opencv_inpainting.py --image examples/example01.png --mask examples/mask01.png

# import the necessary packages
import argparse
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", type=str, required=True,
help="path input image on which we'll perform inpainting")
ap.add_argument("-m", "--mask", type=str, required=True,
help="path input mask which corresponds to damaged areas")
ap.add_argument("-a", "--method", type=str, default="telea",
choices=["telea", "ns"],
help="inpainting algorithm to use")
ap.add_argument("-r", "--radius", type=int, default=3,
help="inpainting radius")
args = vars(ap.parse_args())

# initialize the inpainting algorithm to be the Telea et al. method
flags = cv2.INPAINT_TELEA

# check to see if we should be using the Navier-Stokes (i.e.,Bertalmio
# et al.) method for inpainting
if args["method"] == "ns":
flags = cv2.INPAINT_NS

# load the (1) input image (i.e., the image we're going to perform
# inpainting on) and (2) the mask which should have the same input
# dimensions as the input image -- zero pixels correspond to areas
# that *will not* be inpainted while non-zero pixels correspond to
# "damaged" areas that inpainting will try to correct
image = cv2.imread(args["image"])
mask = cv2.imread(args["mask"])
mask = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)

# perform inpainting using OpenCV
output = cv2.inpaint(image, mask, args["radius"], flags=flags)

# show the original input image, mask, and output image after
# applying inpainting
cv2.imshow("Image", image)
cv2.imshow("Mask", mask)
cv2.imshow("Output", output)
cv2.waitKey(0)
Loading