{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "import os\n", "import torch\n", "import matplotlib.pyplot as plt\n", "import torchvision.transforms.functional as trans_f\n", "\n", "rootdir = os.path.abspath(sys.path[0] + '/../')\n", "sys.path.append(rootdir)\n", "torch.cuda.set_device(2)\n", "print(\"Set CUDA:%d as current device.\" % torch.cuda.current_device())\n", "\n", "from components import refine\n", "from utils import img\n", "\n", "img = img.load(os.path.join(rootdir, \"data/gas_2021.01.04_all_in_one/output/mid_0536.png\"))\n", "\n", "fe = 0.2\n", "leng_sigma = [0,3,5]\n", "\n", "mean, enhanced = refine.constrast_enhance(img, 3, 0.5)\n", "img.save(enhanced, \"mid_enhanced.png\")\n", "\n", "plt.figure(figsize=(12,12))\n", "plt.subplot(121)\n", "img.plot(img)\n", "plt.title('Original')\n", "plt.axis('off')\n", "plt.subplot(122)\n", "img.plot(enhanced)\n", "plt.title('Enhanced')\n", "plt.axis('off')\n", "plt.show()\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.9 64-bit ('pytorch': conda)", "name": "python379jvsc74a57bd0660ca2a75467d3af74a68fcc6f40bc78ab96b99ff17d2f100b5ca821fbb183f2" }, "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.9" }, "orig_nbformat": 2 }, "nbformat": 4, "nbformat_minor": 2 }