{ "cells": [ { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1190\n" ] } ], "source": [ "import cv2\n", "vidcap = cv2.VideoCapture(\"concat_mono-fg_realtime.mp4\")\n", "success,image = vidcap.read()\n", "count = 0\n", "while success :\n", " grayimage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n", " if count < 926 and count >= 920:\n", " cv2.imwrite(\"betterimages/innerfolder/fram%d.jpg\" % count, grayimage)\n", " success, image = vidcap.read()\n", " count += 1\n", "print(count)" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(512, 640)\n", "(512, 640)\n", "(512, 640)\n", "(512, 640)\n", "(512, 640)\n", "(512, 640)\n" ] } ], "source": [ "from PIL import Image\n", "import numpy as np\n", "for i in range(920,926):\n", " im = Image.open(\"betterimages/innerfolder/fram\" + str(i) + \".jpg\")\n", " print(np.array(im).shape)\n", " im.save(\"betterimages/innerfolder/fram\" + str(i) + \".tiff\", 'TIFF')" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "591360\n", "327680\n" ] } ], "source": [ "print(672*880*1190)\n", "print(512*640*1190)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5541125541125541" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "327680/591360" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.421875" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "27/64" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(512, 512)\n", "(512, 640)\n", "(512, 640)\n" ] } ], "source": [ "im = Image.open(\"betterimages/innerfolder/fram\" + str(i) + \".jpg\")\n", "def create_gaussian(l=5, sig=1.):\n", " \"\"\"\n", " creates gaussian kernel with side length `l` and a sigma of `sig`\n", " \"\"\"\n", " ax = np.linspace(-(l - 1) / 2., (l - 1) / 2., l)\n", " gauss = np.exp(-0.5 * np.square(ax) / np.square(sig))\n", " kernel = np.outer(gauss, gauss)\n", " return kernel / np.sum(kernel)\n", "\n", "kernel = create_gaussian(512)\n", "print(kernel.shape)\n", "im = np.array(im)\n", "print(im.shape)\n", "print((kernel@im).shape)" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "320.5" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "205120/640" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.8.10 64-bit", "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.10" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" } } }, "nbformat": 4, "nbformat_minor": 2 }