s444380-wko/wko-01.ipynb

1893 lines
6.5 MiB
Plaintext
Raw Normal View History

2022-10-16 12:07:57 +02:00
{
"cells": [
{
"cell_type": "markdown",
"id": "dfb11bac",
"metadata": {},
"source": [
"![Logo 1](img/aitech-logotyp-1.jpg)\n",
"<div class=\"alert alert-block alert-info\">\n",
"<h1> Widzenie komputerowe </h1>\n",
"<h2> 01. <i>Wprowadzenie do widzenia komputerowego</i> [laboratoria]</h2> \n",
"<h3>Andrzej Wójtowicz (2021)</h3>\n",
"</div>\n",
"\n",
"![Logo 2](img/aitech-logotyp-2.jpg)"
]
},
{
"cell_type": "markdown",
"id": "7c64b51d",
"metadata": {},
"source": [
"# Biblioteka OpenCV\n",
"\n",
"Podczas zajęć będziemy poruszali zagadnienia związane z [widzeniem komputerowym](https://en.wikipedia.org/wiki/Computer_vision) (ang. *computer vision*, CV). Tę tematykę możemy traktować jako rozwinięcie, czy też bardziej zaawansowaną formę [prztwarzania obrazów](https://en.wikipedia.org/wiki/Digital_image_processing) (ang. *image processing*, IP), gdzie tym razem będziemy starali się wyciągnąć pewną bardziej zaawansowaną wiedzę płynącą z obrazów statycznych lub wideo (cf. dyskusja na [Artificial Intelligence Stack Exchange](https://ai.stackexchange.com/a/13588)). Przedmiot ma formę laboratoryjną, zatem główną dyskusję dotyczącą zakresu obu dziedzin zostawimy w ramach dodatkowej literatury uzupełniającej.\n",
"\n",
"Standardem dla algorytmów z dziedzin IP/CV jest biblioteka [OpenCV](https://opencv.org/), która implementuje wiele z tych algorytmów oraz jest aktywnie rozwijana przez społeczność. Sama biblioteka posiada interfejsy do wielu języków programowania, natomiast my skupimy się na języku [Python](https://www.python.org/), który będzie dla nas idealny na potrzeby intensywnego prototypowania. Dokumentację online będzie głównie prowadziła do języka C++, ponieważ nie ma dedykowanej online dla Pythona, ale argumenty funkcji i metod są analogiczne.\n",
"\n",
"Początkowe zajęcia będą głównie dotyczyły zagadnień IP, tak aby zapoznać się z biblioteką OpenCV, a dalsze zajęcia będą już związane z CV.\n",
"\n",
"## Instalacja\n",
"\n",
"Materiały do zajęć Jupyter Notebook są tworzone na serwerze JupyterHub z kernelem Python 3. Pominiemy tutaj tworzenie wirtualnego środowiska, jednak należy mieć na uwadze, że poniższe polecenia mogą być też przydatne podczas próby uruchomienia notebooków lub programów na własnym komputerze.\n",
"\n",
"Poniższe polecenie wyświetla używaną wersję Pythona:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8fda1098",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.9.2\n"
]
}
],
"source": [
"import platform\n",
"print(platform.python_version())"
]
},
{
"cell_type": "markdown",
"id": "c8e7b1e3",
"metadata": {},
"source": [
"Niezbędne moduły zainstalujemy poprzez menadżer `pip`. Sama biblioteka OpenCV, abstrahując od np. paczek debianowych, posiada [4 możliwe opcje instalacji](https://pypi.org/project/opencv-contrib-python/). My zainstalujemy pełną wersję tej biblioteki, a dodatkowo doinstalujemy pakiety związane m.in. wyświetlaniem grafiki oraz uczeniem maszynowym."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "78e42f58",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: opencv-contrib-python==4.5.3.56 in /home/students/s444380/.local/lib/python3.9/site-packages (4.5.3.56)\n",
"Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.19.5)\n",
"Requirement already satisfied: scipy in /usr/lib/python3/dist-packages (1.6.0)\n",
"Requirement already satisfied: matplotlib in /usr/lib/python3/dist-packages (3.3.4)\n",
"Requirement already satisfied: scikit-learn in /usr/lib/python3/dist-packages (0.23.2)\n"
]
}
],
"source": [
"!pip3 install --user --disable-pip-version-check opencv-contrib-python==4.5.3.56 numpy scipy matplotlib scikit-learn"
]
},
{
"cell_type": "markdown",
"id": "1d241431",
"metadata": {},
"source": [
"Sama biblioteka posiada też własne moduły związane z wyświetlaniem grafiki (moduł *HighGUI*) oraz z uczeniem maszynowym (moduł *ml*), jednak my raczej nie będziemy z nich korzystać podczas zajęć (aczkolwiek mogą być przydatne podczas realizacji projektu).\n",
"\n",
"Wszystkie moduły, algorytmy i zmienne są dostępne z poziomu modułu `cv2`:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8eca2db5",
"metadata": {},
"outputs": [],
"source": [
"import cv2 as cv"
]
},
{
"cell_type": "markdown",
"id": "82701dba",
"metadata": {},
"source": [
"Poniższym poleceniem możemy również sprawdzić wersję zainstalowanej biblioteki:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f34f551a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.5.3\n"
]
}
],
"source": [
"print(cv.__version__)"
]
},
{
"cell_type": "markdown",
"id": "7a39875c",
"metadata": {},
"source": [
"## Obrazy jako tablice\n",
"\n",
"Obraz możemy traktować jako standardową tablicę [NumPy](https://www.numpy.org/) zawierającą dane dotyczące danych pikseli. Im większa liczba pikseli w obrazie, tym większa jest jego rozdzielczość. Intuicyjnie można przyjąć, że piksele są niewielkimi blokami informacji ułożonymi w postaci siatki dwuwymiarowej, a głębokość piksela odnosi się do informacji o kolorze. Aby obraz mógł być przetworzony przez komputer, to taki obraz musi zostać przekonwertowany na postać binarną. Kolor obrazu można obliczyć w następujący sposób:\n",
"\n",
"Liczba kolorów (odcieni) = 2<sup>*bpp*</sup>, gdzie *bpp* oznacza bity na piksel.\n",
"\n",
"Większa liczba bitów na piksel daje więcej możliwych kolorów na obrazach.\n",
"\n",
"| Bity na piksel | Liczba kolorów |\n",
"| :------------: | :------------: |\n",
"| 1 | 2<sup>1</sup> = 2 |\n",
"| 2 | 2<sup>2</sup> = 4 |\n",
"| 3 | 2<sup>3</sup> = 8 |\n",
"| 4 | 2<sup>4</sup> = 16 |\n",
"| 8 | 2<sup>8</sup> = 256 |\n",
"| 16 | 2<sup>16</sup> = 65536 |\n",
"\n",
"Spójrzmy na trzy typowe reprezentacje obrazów.\n",
"\n",
"### Obraz czarno-biały\n",
"\n",
"Obraz binarny składa się z 1 bita na piksel, a więc może mieć tylko dwa możliwe kolory, tj. czarny lub biały. Kolor czarny jest reprezentowany przez wartość 0, a 1 oznacza biel (czasem w użyciu są reprezentacje, które mają odwrotne wartości czerni i bieli).\n",
"\n",
"![Obraz czarno-biały jako tablica bitów](img/binary-image.png)\n",
"\n",
"### Obraz w skali odcieni szarości\n",
"\n",
"Obraz w skali szarości składa się z 8 bitów na piksel. Oznacza to, że może mieć 256 różnych odcieni, przy czym 0 pikseli będzie reprezentować kolor czarny, a 255 oznacza biel.\n",
"\n",
"![Przykładowy obraz w skali odcieni szarości](img/lena-grayscale.png)\n",
"\n",
"### Obraz kolorowy\n",
"\n",
"Kolorowe obrazy w standardowej formie są reprezentowane jako połączenie barwy czerwonej, niebieskiej i zielonej - wszystkie inne kolory można uzyskać, mieszając te podstawowe kolory we właściwych proporcjach.\n",
"\n",
"![Składowe RGB](img/rgb-colors.png)\n",
"\n",
"Kolorowy obraz składa się również z 8 bitów na piksel, z tym że na taki obraz składają się 3 kanały (czerwony, zielony i niebieski). W rezultacie 256 różnych natężeń danego koloru podstawowego można przedstawić za pomocą 0 oznaczającego najmniej intensywny i 255 najbardziej intensywny. Dla poniższego obrazu pawiana:\n",
"\n",
"![Obraz pawiana](img/baboon.png)\n",
"\n",
"podstawowe parametry dotyczące wymiarów prezentują się następująco:\n",
"\n",
"```plaintext\n",
"Shape\n",
"(288, 289, 3)\n",
"288: Pixel height (wysokość w pikselach)\n",
"289: Pixel width (szerokość w pikselach)\n",
"3: color channel (liczba kanałów)\n",
"```\n",
"\n",
"Taki obraz możemy reprezentować w postaci trójwymiarowej tablicy:\n",
"\n",
"![Kanały RGB obrazu pawiana](img/baboon-3d.png)"
]
},
{
"cell_type": "markdown",
"id": "650cae81",
"metadata": {},
"source": [
"## Wczytywanie obrazów\n",
"\n",
"Przy użyciu funkcji [`cv.imread()`](https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56) możemy odczytać obraz. Pierwszy argument to lokalizacja pliku. Obraz powinien znajdować się w katalogu roboczym lub powinna zostać podana ścieżka bezwzględna do pliku.\n",
"\n",
"Drugi argument (opcjonalny) jest flagą oznaczającą w jaki sposób obraz powinien zostać wczytany:\n",
"\n",
"* [`cv.IMREAD_COLOR`](https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html#gga61d9b0126a3e57d9277ac48327799c80af660544735200cbe942eea09232eb822) - wczytuje kolorowy obraz z pominięciem przezroczystości; flaga domyślna,\n",
"* [`cv.IMREAD_GRAYSCALE`](https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html#gga61d9b0126a3e57d9277ac48327799c80ae29981cfc153d3b0cef5c0daeedd2125) : wczytuje obraz w skali odcieni szarości,\n",
"* [`cv.IMREAD_UNCHANGED`](https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html#gga61d9b0126a3e57d9277ac48327799c80aeddd67043ed0df14f9d9a4e66d2b0708) : wczytuje obraz razem z kanałem alfa (przezroczystość).\n",
"\n",
"Zamiast trzech powyższych flag można alternatywnie przekazać odpowiednio 1, 0 lub -1."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d7fccc7d",
"metadata": {},
"outputs": [],
"source": [
"image = cv.imread(\"img/baboon.png\", cv.IMREAD_COLOR)"
]
},
{
"cell_type": "markdown",
"id": "d9024a2d",
"metadata": {},
"source": [
"Sprawdźmy typ zmiennej:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "78c727fe",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'numpy.ndarray'>\n"
]
}
],
"source": [
"print(type(image))"
]
},
{
"cell_type": "markdown",
"id": "7c488a2d",
"metadata": {},
"source": [
"Sprawdźmy kształt tablicy:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "67bafe94",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(288, 289, 3)\n"
]
}
],
"source": [
"print(image.shape)"
]
},
{
"cell_type": "markdown",
"id": "68d3db9e",
"metadata": {},
"source": [
"[Typ danych](https://numpy.org/doc/stable/user/basics.types.html) tablicy:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "8463a5df",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"uint8\n"
]
}
],
"source": [
"print(image.dtype)"
]
},
{
"cell_type": "markdown",
"id": "243e1fd8",
"metadata": {},
"source": [
"Jak widać, poszczególne piksele na kanałach są 8-bitowymi liczbami całkowitymi bez znaku."
]
},
{
"cell_type": "markdown",
"id": "185a63ad",
"metadata": {},
"source": [
"## Wyświetlanie obrazów przy pomocy Matplotlib\n",
"\n",
"W notebooku Jupyter najwygodniej wyświetla się obrazy przy pomocy biblioteki [Matplotlib](https://matplotlib.org/), a dokładniej modułu `pyplot`:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "c4516873",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import matplotlib\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "7e320379",
"metadata": {},
"source": [
"Przed wyświetleniem obrazu musimy dokonać drobnej konwersji obrazu. OpenCV domyślnie wczytuje obraz w formacie BGR, natomiast Matplotlib pracuje na obrazie w formacie RGB. Do konwersji użyjemy funkcji [`cv.cvtColor()`](https://docs.opencv.org/4.5.3/d8/d01/group__imgproc__color__conversions.html#ga397ae87e1288a81d2363b61574eb8cab), której pierwszym argumentem jest konwertowany obraz, a drugim sposób konwersji (w tym wypadku definiowany przez stałą [`cv.COLOR_BGR2RGB`](https://docs.opencv.org/4.5.3/d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0ad3db9ff253b87d02efe4887b2f5d77ee)). *Nota bene*, czasami lepiej jest operować w przestrzeni barw [HSV](https://pl.wikipedia.org/wiki/HSV_(grafika)) niż RGB."
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "bd083db2",
"metadata": {},
"outputs": [],
"source": [
"image2 = cv.cvtColor(image, cv.COLOR_BGR2RGB)"
]
},
{
"cell_type": "markdown",
"id": "f8b4ae77",
"metadata": {},
"source": [
"Po przekonwertowaniu obrazu możemy wyświetlić go przy pomocy `pyplot`. Użyjemy do tego funkcji [`matplotlib.pyplot.imshow()`](https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow):"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "e39ea012",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ee395eb0>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Sa9tW5bfh/1muapdneIW774XVWZSJA0KlpkCBBlgV4DckeSOWuwT2SKyRYItspPfgIT5Ddh0h51sEiBgyYJkIE2KQUZG8cp7yl2satZqzB1ByRTEgC0zIsA7gIOHe7DfOfusvdYcc45/JUophU/1qT7Vp/pUn+q3uORv+g18qk/1qT7Vp/pU/7b61Kw+1af6VJ/qU/3W16dm9ak+1af6VJ/qt74+NatP9ak+1af6VL/19alZfapP9ak+1af6ra9PzepTfapP9ak+1W99fWpWn+pTfapP9al+6+tTs/pUn+pTfapP9Vtfn5rVp/pUn+pTfarf+vrUrD7Vp/pUn+pT/dbXb7RZ/f2///f50Y9+RNu2/OEf/iH/5J/8k9/k2/lUn+pTfapP9Vtav7Fm9Y/+0T/ib/7Nv8nf+Tt/h//+v//v+Wt/7a/xn//n/zm/+MUvflNv6VN9qk/1qT7Vb2mJ35SR7X/yn/wn/NW/+lf5B//gH/zqe3/5L/9l/sv/8r/kT/7kT34Tb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G+TNi240e/9/t8+bOf4/xMihFKRgqBup4yBFAKrHnEGotSGmky6/mC8LGeNZuWfT+QCpzHkWWeWZ3DNi1v7+8xTYM
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(image2)"
]
},
{
"cell_type": "markdown",
"id": "fc1c34db",
"metadata": {},
"source": [
"Zwróćmy uwagę, że piksel o współrzędnych `(0, 0)` znajduje się w lewym górnym rogu.\n",
"\n",
"Można też obejść się bez konwersji i po prostu odwrócić w locie kanały w tablicy `numpy`:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "aa374723",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ee3067c0>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Sa9tW5bfh/1muapdneIW774XVWZSJA0KlpkCBBlgV4DckeSOWuwT2SKyRYItspPfgIT5Ddh0h51sEiBgyYJkIE2KQUZG8cp7yl2satZqzB1ByRTEgC0zIsA7gIOHe7DfOfusvdYcc45/JUophU/1qT7Vp/pUn+q3uORv+g18qk/1qT7Vp/pU/7b61Kw+1af6VJ/qU/3W16dm9ak+1af6VJ/qt74+NatP9ak+1af6VL/19alZfapP9ak+1af6ra9PzepTfapP9ak+1W99fWpWn+pTfapP9al+6+tTs/pUn+pTfapP9Vtfn5rVp/pUn+pTfarf+vrUrD7Vp/pUn+pT/dbXb7RZ/f2///f50Y9+RNu2/OEf/iH/5J/8k9/k2/lUn+pTfapP9Vtav7Fm9Y/+0T/ib/7Nv8nf+Tt/h//+v//v+W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u5+b2nrCuDF3HMGzZ7Q5oodjtXpnHhcv5zHffPfG9Dz/i6eWZb777jvHiUKpjt9uz2e3Z7vcoY1jdyryuLOtCj2C32XG+TNi240e/9/t8+bOf4/xMihFKRgqBup4yBFAKrHnEGotSGmky6/mC8LGeNZuWfT+QCpzHkWWeWZ3DNi1v7+8xTYM
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(image[..., ::-1])"
]
},
{
"cell_type": "markdown",
"id": "232c3da7",
"metadata": {},
"source": [
"Sprawdźmy kolejny plik:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "bccd478c",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAGdCAYAAAAv9mXmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVaElEQVR4nO3dbWyVhd3H8X8pWlBLnZgSiYiQbAHBBx6MUdC5aEh8ykgWN406o8kiW1WQxCjTbdEJDXswJjpqajbDZlBebEaWzG3ERZA5I7agZlskzkUaHWMupkVY6mjP/eK+be56TdYD/HudUz+f5LzgyjlcvxyBr1dPe05DpVKpBAAcZePKHgDA2CQwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkGL8aJ9wcHAw3n333Whubo6GhobRPj0AR6BSqcS+ffti6tSpMW7coa9RRj0w7777bkybNm20TwvAUdTT0xOnnnrqIe8z6oFpbm4e7VMCNWrixIllTyg4ePBg2RMK/v3vf5c9oWAk/5aPemB8WQzKUYt/92wamVra9NHbV45kkxf5AUghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIcVmDWrVsXM2bMiAkTJsSCBQvihRdeONq7AKhzVQdm48aNsWLFirjnnntix44dceGFF8Zll10Wu3fvztgHQJ1qqHz01pgjdN5558X8+fOjo6Nj6Njs2bNj6dKl0d7e/l8f39fXFy0tLdUvBY5ILb0j70e8Xf/I1NLb9X+UjN7e3pg0adIh71vVFcyHH34YXV1dsWTJkmHHlyxZEi+++OJ/fEx/f3/09fUNuwEw9lUVmPfeey8GBgZiypQpw45PmTIl9uzZ8x8f097eHi0tLUM3n2YJ8OlwWC/yf/xSu1KpfOLl96pVq6K3t3fo1tPTczinBKDOVPWJlieffHI0NjYWrlb27t1buKr5SFNTUzQ1NR3+QgDqUlVXMMcee2wsWLAgNm/ePOz45s2b44ILLjiqwwCob1VdwURErFy5Mm644YZYuHBhnH/++dHZ2Rm7d++OZcuWZewDoE5VHZivfOUr8c9//jPuv//++Nvf/hZz586NX/3qVzF9+vSMfQDUqap/DuZI+TkYKIefgxkZPwdzaGk/BwMAIyUwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUlT9ZpdjVS2+J9LFF19c9oSCv/71r2VPKHjzzTfLnlAwODhY9oSC008/vewJBR//+PVasHPnzrInFNTSpkqlEv39/SO6rysYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0CK8WWevKGhoczTD3PxxReXPaFg9erVZU8oeOedd8qeULBu3bqyJxTs27ev7AkFX//618ueUHDWWWeVPaHg2WefLXtCwe7du8ueMGRwcDD27Nkzovu6ggEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApqgpMe3t7nHvuudHc3Bytra2xdOnSeOONN7K2AVDHqgrMli1boq2tLV566aXYvHlzHDx4MJYsWRL79+/P2gdAnarqA8d+/etfD/v1448/Hq2trdHV1RUXXXTRUR0GQH07ok+07O3tjYiIk0466RPv09/fH/39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GgBQCA0AKgQE
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x_small = cv.imread(\"img/x_small.jpg\", cv.IMREAD_GRAYSCALE)\n",
"plt.imshow(x_small, cmap = 'gray');"
]
},
{
"cell_type": "markdown",
"id": "2ba47521",
"metadata": {},
"source": [
"Wczytaliśmy obraz w skali odcieni szarości. Podczas wyświetlania obrazu możemy ustawić mapę kolorów (parametr `cmap`). Dodatkowo, jeśli na końcu polecenia damy średnik (`;`), to w wynikowej komórce notebooka nie będzie się wyświetlał zwracany typ.\n",
"\n",
"Czasami warto również wyświetlić pasek z informacją o tym jaka wartość odpowiada za dany odcień:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "066b4778",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAecAAAGdCAYAAAAotLvzAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAjUUlEQVR4nO3de3BU9f3G8WcJsAm4iQSa2xAwdHBAggqBQQEl/MAoCpbiiPeiUgfKRWLEC2LblEq20IqZgRInDIUIcvmjInTqhahjkFLGEECQOqCVStCkqUyaEMQNCfv7o7DjuiC7uZ3v8n2/Zs6MOXt2z4cd5fH5ns0el9/v9wsAABijk9MDAACAYIQzAACGIZwBADAM4QwAgGEIZwAADEM4AwBgGMIZAADDEM4AABimc0ef8OzZs/rqq6/k8Xjkcrk6+vQAgFbw+/06efKk0tLS1KlT+/W7b7/9Vo2Nja1+na5duyo2NrYNJupYHR7OX331ldLT0zv6tACANlRZWanevXu3y2t/++23ysjIUHV1datfKyUlRUePHo26gO7wcPZ4PB19SgCGiouLc3qEEE1NTU6PEOLMmTNOjxCiPf8ub2xsVHV1tSorKxUfH9/i16mvr1d6eroaGxsJ50thKRtwhon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wks3NmWvOAAAYhuYMADCSzc2ZcAYAGMnmcGZZGwAAwxDOAAAjnW/OrdkitWPHDk2aNElpaWlyuVx6/fXXgx5/+OGH5XK5grYbbrgh6Bifz6e5c+eqV69e6t69u+68804dP348ojkIZwC
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(x_small, cmap = 'gray');\n",
"plt.colorbar();"
]
},
{
"cell_type": "markdown",
"id": "c561f1ea",
"metadata": {},
"source": [
"## Proste operacje\n",
"\n",
"Możemy sprawdzić, że obraz jest w istocie tablicą NumPy o wartościach w zakresie od 0 do 255:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "fd384995",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0 0 0 0 0 0 1 10 6 1]\n",
" [ 0 9 71 39 4 2 33 100 54 8]\n",
" [ 1 70 198 173 71 58 158 202 133 25]\n",
" [ 1 25 150 208 201 203 221 172 57 3]\n",
" [ 0 2 43 186 243 245 187 53 4 0]\n",
" [ 0 4 90 207 231 236 189 87 9 0]\n",
" [ 0 37 160 210 137 156 209 195 63 2]\n",
" [ 0 28 112 114 23 28 128 185 71 3]\n",
" [ 0 4 25 15 2 1 13 58 10 0]\n",
" [ 0 0 0 0 0 0 0 0 0 0]]\n"
]
}
],
"source": [
"print(x_small)"
]
},
{
"cell_type": "markdown",
"id": "794d3cb6",
"metadata": {},
"source": [
"Wracając do samej biblioteki Matplotlib, możemy również np. sterować rozmiarem wyświetlanego obrazu oraz nadać mu tytuł:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "5998b09d",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAIYCAYAAACbuB7uAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWX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FC5u+NnXq1Hj//fcjImLu3LnRq1evXDbCHiEDCvb+++9nEZFFRDZy5Mjduq9BgwZlEZFdcMEF2f33359179696b7/9nLooYdmb7/9dpZlWXbbbbdlRUVFOzxu1KhRWV1d3Q4fa+bMmTu8zd9e9tprr+yRRx5pce8FF1yQRUQ2aNCgnf5+dldtbW02cODALCKy/fbbL3v33XezxYsXN209++yzd/sxoLNzhg67oXfv3jFo0KCIiFi3bl3MmTMnGhsbd+s+161bF9/97nfj4IMPjvnz58ezzz4bTzzxRJx33nkREfHqq6/GVVddFY8++mhcffXVMXbs2Pj5z38eq1evjt/85jdxyimnRMSnZ/i33HLLDh9j69at0b9//7j00kvjgQceiJUrV0ZVVVX813/9V/zgBz+IvffeO7Zs2RLf+ta3duktY+2trKws5s6dGxER7733XlxyySVNZ+19+vSJn/zkJ3nOgz1D3n+jgM7u9ttvb3ZmO2jQoOyyyy7Lfv7zn2evvfbaLt/PtjPaiMiOPfbYbPPmzdsdc+aZZ2YRkRUXF2e9e/fOvvGNb2Rbt25tdszWrVuzL3/5y1lEZH369Mk++eST7e5n/fr12ccff9zilurq6uyAAw7IIiI777zzdnhMR56hb3POOeds90zCAw880Gb3D52ZM3TYTVdeeWVcdNFFTb9+44034q677opzzz03Dj744PjCF74QZ599djz22GORZdku3ee9994be+2113bXX3rppRHx6Yvx/vrXv0ZlZWUUFxc3O6a4uDguvvjiiIh4//334+WXX97ufgYPHvyZb6E78MAD4+qrr46IiCVLluzy7vb2k5/8JMrKypp+fdJJJzU9cwGfd4IOu6lLly7xs5/9LJYuXRonnnhidOnS/I/VO++8E4sWLYozzjgjvvSlL8Wf/vSnz7y/kSNHxmGHHbbDr40YMaLpf5944onRu3fvFu9jm9dff32nv4fa2tpYv359vPTSS/Hiiy/Giy++2PQXim1f2xOsW7eu2Yv9BgwYkOMa2LN4Hzq0kZNOOilOOumk+OCDD2LlypWxevXqqKqqihUrVkRNTU1ERKxevTqOO+64qKqqiv79++/wfg499NAWH2OfffZp9XEtvdr9jTfeiNtvvz0ee+yxeOONNz7jd/bpv1sPHTr0M49pb5s3b2565mGbBQsWxPnnn++95xDO0KHN7bvvvnHaaafFjTfeGI899li88847MX/+/Nh3330jIuLtt9+OG264ocXb7+ip9m3+9ux/V49raGjY7utLly6Nww8/PO66666dxjwi4qOPPtrpMe3t+uuvb3qm4JZbbomePXtGlmVx8cUXR319fc7rIH+CDu2spKQkJk2aFA899FDTdY888shuvxq+UO+//35861vfii1btsTee+8dN954Y/zhD3+ITZs2RX19fWRZFlmWxeOPP950m7z/Df2ZZ56Jf/u3f4uIT58Jue666+JHP/pRRHz6qv9t/xs+zwQdOsg//dM/NX1s6QcffND0gSgd7T//8z/jL3/5S0R8+heLmTNnxpe//OXYf//9o3v37k3HffDBB7ns+3uffPJJfOc734nGxsbo2bNn3HPPPRERcfnll8eYMWMiIuLWW2+NF198Mc+ZkDtBhw70ty/i+vsXz3WUl156KSI+fQ/9iSee2OJxq1ev7qhJn2n27NlNsZ41a1bT+/63/US2rl27xieffBLf+973cnvWA/YEgg4dZMuWLU1vIevVq1eLr1Bvb1u3bo2IT3+0a0sB3LJlS9x///0dOWuHXn755Zg9e3ZERIwdOzamTp3a7OsjR46Mq666KiIiVq1a1fThM/B5JOiwGz788MMYO3Zs/OpXv/rMs8PGxsaYOnVq0yvOzzjjjBZ/tnd7O+SQQyLi01eN/+IXv9ju6w0NDfHd73433nrrrY6e1kxjY2N85zvfiY8//ji6desW99577w6f1Zg5c2bT5+jPmDEj/u///q+jp8IewdvWYDc988wzcfrpp8cBBxwQEydOjGOOOSYGDRoUZWVl8Ze//CWee+65mD9/frzwwgsREVFeXp7ri7i++c1vxg9/+MOor6+PCy+8MNauXRsnnHBC9OrVK1566aW48847o6qqKsaNGxcrV67Mbeedd94Zq1atioiIa6+9NoYPH77D40pLS6OysjL+8R//Merq6mLKlCmxePHijpwKe4Y8P6YOOruPPvoo+8IXvrDTH3Sy7XLIIYdkq1ev3uF97epHpW67r5kzZ7Z4zPr165uOW7BgwXZfnz9/ftalS5cWd5511lnZ//zP/zT9+ne/+91299GeH/365z//OevZs2cWEdmwYcOyv/71rzu9zUUXXdS09xe/+EWrHxM6O0+5w24oLS2NN998M1auXBk33XRTnHzyyTF06NDo2bNnFBcXR69evWLYsGFx1llnxcKFC+PFF1+M0aNH5z07Jk2aFCtWrIiJEyfG/vvvH926dYv+/fvHSSedFIsWLYqHH354u4+U7UiXXHJJbN68OYqKiuLee++NkpKSnd7m9ttvj379+kXEpz9WdduH+cDnRVGW7SEf0gwAFMwZOgAkQNABIAGCDgAJEHQASICgA0ACBB0AEtDhnxTX2NgYb731VpSVleX20ZcA0FlkWRZ1dXUxYMCAz/yhTh0e9LfeeqvpR0gCALumuro6DjzwwBa/3uFBLysr6+iHBNgj9ejRI+8JBdn2E/s6o08++STvCQXbWT87POieZgfaWmf974rdHa8zbt/2ga472+5FcQCQAEEHgAQIOgAkQNABIAGCDgAJEHQASICgA0ACBB0
"text/plain": [
"<Figure size 600x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize = [6, 6])\n",
"plt.imshow(x_small, cmap = 'gray')\n",
"plt.title('Small X', fontsize = 20);"
]
},
{
"cell_type": "markdown",
"id": "059710ee",
"metadata": {},
"source": [
"Niektóre parametry Matlplotlib (np. `figsize`) możemy ustawić na domyślne przy pomocy [`matplotlib.rcParams`](https://matplotlib.org/stable/tutorials/introductory/customizing.html#matplotlib-rcparams).\n",
"\n",
"Podczas wczytywania obrazów zawierających przezroczystość należy zwrócić uwagę na sposób wczytywania obrazu:"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "77861dde",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAADXCAYAAAAwVqpgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAA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uvgZQic8tlQyHAUfa4dWm9LYzbQosn2fitR1iM/So1f/vIAST3O7kCFAMfSFnakIvIwh2me1UTDSTJsgzjByYBdoAw8QKabsPCtvBkWwJgYqqFzfxoM2tgCIP7D2lnzZTooBg+sP+mxJ3hfefZjoMzLmv2w0ocIHdpBIUpZK7HlXovFgxZ1Qw9EqVzYAb50Fl/vDpMjOdyoBgir/dnA9QFLpoKxj+IwMMBUYAAoHM7F9cgVTUv2neTHJmoj0j5p/0NhUEex/YUqnWsuA+U5YPeU7Y35zGRpS5SUtrW2YEzulvYnhbBrhsaU6SGbPBuH/H4Q9C14AOkMwqvYmm0FWPxXnQ602+lMIwYHopFLvASLOacUTCgD4/9KRY/ZTzAUpQwY73M50KLdkLQwghQNdcuXKhJEsk7VI//OJduH0e1JVZs485Zbpq7ZfvQmey7XUU2LyhkkELLsC3Turq41Tyx5wPUEACAyFEjjPAboel06GlC1o6M50gYaaggmPndUnKtTW6WsXMYMAwdGZ+K3AGOJDg52pLYE45eCyIBHp8cLhVN45NNY+WbsZCCJEF7AYsmArVJjV+FtmlpVMHKVY0lAUd7yyyQ30SDckrC6GhBlwO86t6B3zw7rnUeoKFSYAihBB
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"img_lfl = cv.imread(\"img/linux_foundation.png\", cv.IMREAD_COLOR)\n",
"plt.imshow(img_lfl);"
]
},
{
"cell_type": "markdown",
"id": "46deb78b",
"metadata": {},
"source": [
"Mamy tutaj obraz 4-kanałowy, przez co musimy go wczytać jako `cv.IMREAD_UNCHANGED`, no i dodatkowo odpowiednio go przekonwertować:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "ce0a9061",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAADXCAYAAAAwVqpgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYX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xd3gOUL37xizzzzDP8x3/8BxaLZWJcic1mw2AwIEkSDz74II8++ih1dXXU1dXx6KOPYjQaue+++/JdnFmhUctYjHqMWjUqlfgBm21mVRaNWoUsYsMPtFgiyX/sO8a+Iy1YTflbgXhFbRl/cOMalle7MJlMeduvIAhXlvcA5Tvf+Q4A27Ztu+D5H/zgB3zmM58B4Ktf/SqxWIwHHngAn8/Hxo0b2bVrFxaLJd/FmRWyLKHTqNHptOIOaw5oJEUEJ1ehVqswGbSkMxn0uvFA+nJjvq5Go1aj06oxGTQYdBp02qmtOnw1kiSh02jQazWY9Bp0GjVq9aW7V2RZxqDXYtRpieoS9I2M0TeS1+IgybBtzRLSovtQEGbVjHTxXI0kSezYsYMdO3bk+/CCIFyCs7iQzY01hGMJllS4sJsNqNXT+/N3FxWwtDLN1hV11Fe7qSl1TDvYuRSVSkVtuZO0ImM16llc4aTEYb/ktnqdjpW1ZRTZLPjD+Rt38m7LF5VSaDNdNkgSBGFmzNggWUEQ5o8lNZV85sYsqXSaApuVskILOp12WvtqqHbhshtYUqzDYbdRYLPkNUDRaDRsrS+nodRGIOSi3OOiqMB2yW2tVgt3b6olHImRSCbzVoZ3KyywU+W0odVOr74EQZgeEaAIwgdARXkZFeVlV99wEqoqyqiqKGP
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"img_lfl = cv.imread(\"img/linux_foundation.png\", cv.IMREAD_UNCHANGED)\n",
"plt.imshow(cv.cvtColor(img_lfl, cv.COLOR_BGRA2RGBA));"
]
},
{
"cell_type": "markdown",
"id": "9f0f1db3",
"metadata": {},
"source": [
"Możemy również podzielić obraz na poszczególne kanały i ew. ponownie je połączyć, odpowiednio przy pomocy funkcji [`cv.split()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#ga0547c7fed86152d7e9d0096029c8518a) i [`cv.merge()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#ga7d7b4d6c6ee504b30a20b1680029c7b4):"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "60ab993b",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAG7CAYAAAB9x7r2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9aZDk2VXe/eRambXkUplZW2/Ts0gCgUBCMCBsBCYswCAQAtuAAWHAZrGDIITNYvArCQhhIAAZ20CIRSwObPAHQoAQWAo2GWEWSUiMJGbR9PR0ddeamZVZVVlZldv7od7fySeze2Z6hKSZflU3oqO7qzL/y73nnuU5zzk3MRqNRjobZ+NsnI2zcTaexSP5TD/A2TgbZ+NsnI2z8VTjzFidjbNxNs7G2XjWjzNjdTbOxtk4G2fjWT/OjNXZOBtn42ycjWf9ODNWZ+NsnI2zcTae9ePMWJ2Ns3E2zsbZeNaPM2N1Ns7G2TgbZ+NZP86M1dk4G2fjbJyNZ/04M1Zn42ycjbNxNp7148xYnY1nzfjjP/5jJRIJJRIJ/fEf//Ez/TjP6Pjcz/1cJRIJfe7nfu4z/Sj/vxvf8A3foEQiobvuuuuZfpSz8TTGmbE6G3+v4QbmVn/m5+f1nOc8R6961as+7g3Q2TgbZ+PDH2fG6mx8VMfh4aEefvhh/eqv/qo+7/M+T9/0Td+kwWDwTD/W2TgbZ+MOG+ln+gHOxv9/xrd927fp27/92+P/o9FIjUZDf/7nf66f+qmf0vb2tn7pl35J58+f1+te97pn8EnPxtk4G3faODNWZ+MjNpaWlvRJn/RJN/38pS99qb70S79UL37xi3V0dKQ3vOEN+oEf+AFlMpln4CnPxtk4G3fiOIMBz8bHZHziJ36ivviLv1iS1G639cEPfvAZfqKzcTbOxp00zozV2fiYDWdfdbvdp/3922XIvfa1rw2Cx5ONTqejN7zhDfq8z/s8LS8vK5vNamlpSS972cv0p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Sze/E2nU6HaXTt6+6Njc3deHChdv+/Nl4do6zyOpsfFRHPp/XJ3/yJ+vHfuzH9DM/8zOSpD/5kz/Rj/zIjzwjz7O9vf1hfa/T6Tytz6P4V1dXP6z7MZ7K0GHIhsPhTb8bjUb65m/+Zn3Jl3yJ3vKWtzylETk6OvqIPMtTRaFPdh03zNPX+Vit3dl4do6zyOpsfMzGN33TN+l7v/d71Wg09Iu/+Iv6wR/8wY/5M6AAP/uzP1s/93M/d9vfAyp7uuN2o7ePxvilX/ol/eIv/qIk6VM/9VP1nd/5nbr//vt17tw5zc7OKpVKSZK+/uu/Xr/2a7+m0Wj0jD3r7QzW7vLly/rt3/7t2/7e5cuXP1qPdDY+huPMWJ2Nj9lIJpO677779Bd/8Re6ceOGGo3GBOxzO9+Xbh1F+Dg8PHzC31UqFW1tbWlnZ+eWraE+UqNarWp9fV03btz4qN3jqQb073vuuUfvfOc7nxB2bTabH8vH+rBHpVKRJG1tbel5z3ve04ICz8adP85gwLPxMR3eneDp1i8tLCxIemrl+uCDDz7h7174whdKkh566CFdvXr1ad3/6YwXvehFkk7zLM8UDEXt1Zd92Zc9oaEajUa31UHj2TBYu06noz/7sz97hp/mbHysx5mxOhsfs9HpdPSBD3xAkpTL5VStVp/W94FzHnrooSfMv+zs7Ojtb3/7E17jS7/0S+PfP/ZjP/a07v90xstf/nJJp+/8xje+8aN2nycbOAZPZix/+7d/+xmN/p7O+LIv+7L490dz7c7Gs3OcGauz8TEbr3nNayKJ/wVf8AWRM7nd8dKXvlTSKTvvv/yX/3LT73u9nr7pm77pSYkCX/EVXxGdEn72Z382cjpPNB544AH9zu/8ztN6Tkn
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"b, g, r = cv.split(image)\n",
"plt.imshow(b, cmap = 'gray')\n",
"plt.title('Blue channel', fontsize = 20);"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "f8418716",
"metadata": {},
"outputs": [
{
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NxLaWptNYo2m0ZV0cfgkEFxl6wXarSGlmns645cK7t9/D+5m5eHJeWVwguQBElILNsGFod5zPCzkqjB14OV74+PKRpjXsDls2ux1yXVnXQkqSlBUpF1IulJKRArQWjOcjVu9pbEN3c0M3KHbbuh5M08LDwxPeC6y1IGoTQ2h8WLG24e72Dd/74i8A/+bB5X+tfiPNylrLH/7hH/Knf/qn/Ff/1X/1q+//6Z/+Kf/Ff/Ff/No/Z9PtaBpYlpHoL9zeNEgNqQTWkBlki24gxoIQGdsaTLvFmC1aF7SEdZnJMUFKkAOnyytNk7i939MPLSlFvJ/5/PN7xunM8fSRf/WTCWUDxihyAaULn3/xlnfvDNPoGC8z3i/89Kc/Zp7v2e429J3GysLX33xku7tnu7shlZnj8YJQlr4fuLnb0PdvkaawuifW5ZnpfOTzDweMsWy3BiklpfSEGJmXmXbY8Nn7d8zTwvl0YRpHpvPIt998B0UiiyaHwrv3n9O3G7775pFljrx7/xmH3R0ICN7hlkRYC0PboETLPE+8vF7Ybd7QNVu8v2B0x/c+/wGP3z2zTgHvIsFPFAQueHyKJAqqsXTtljxA9jCnhegzX375DffvIjf3d9iu5+b2nrCuDF3HMGzZ7Q5oodjtXpnHhcv5zHffPfG9Dz/i6eWZb777jvHiUKpjt9uz2e3Z7vcoY1jdyryuLOtCj2C32XG+TNi240e/9/t8+bOf4/xMihFKRgqBup4yBFAKrHnEGotSGmky6/mC8LGeNZuWfT+QCpzHkWWeWZ3DNi1v7+8xTYM
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"restored_image = cv.merge((r,g,b))\n",
"plt.imshow(restored_image);"
]
},
{
"cell_type": "markdown",
"id": "9ba6f17e",
"metadata": {},
"source": [
"Dostęp do poszczególnych pikseli odbywa się tak jak w macierzy, czyli podając wiersz i kolumnę. Poniżej możemy zobaczyć zmianę piksela na współrzędnych `(1, 1)`:"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "7a018550",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAGdCAYAAAAv9mXmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVaElEQVR4nO3dbWyVhd3H8X8pWlBLnZgSiYiQbAHBBx6MUdC5aEh8ykgWN406o8kiW1WQxCjTbdEJDXswJjpqajbDZlBebEaWzG3ERZA5I7agZlskzkUaHWMupkVY6mjP/eK+be56TdYD/HudUz+f5LzgyjlcvxyBr1dPe05DpVKpBAAcZePKHgDA2CQwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkGL8aJ9wcHAw3n333Whubo6GhobRPj0AR6BSqcS+ffti6tSpMW7coa9RRj0w7777bkybNm20TwvAUdTT0xOnnnrqIe8z6oFpbm4e7VMCNWrixIllTyg4ePBg2RMK/v3vf5c9oWAk/5aPemB8WQzKUYt/92wamVra9NHbV45kkxf5AUghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIcVmDWrVsXM2bMiAkTJsSCBQvihRdeONq7AKhzVQdm48aNsWLFirjnnntix44dceGFF8Zll10Wu3fvztgHQJ1qqHz01pgjdN5558X8+fOjo6Nj6Njs2bNj6dKl0d7e/l8f39fXFy0tLdUvBY5ILb0j70e8Xf/I1NLb9X+UjN7e3pg0adIh71vVFcyHH34YXV1dsWTJkmHHlyxZEi+++OJ/fEx/f3/09fUNuwEw9lUVmPfeey8GBgZiypQpw45PmTIl9uzZ8x8f097eHi0tLUM3n2YJ8OlwWC/yf/xSu1KpfOLl96pVq6K3t3fo1tPTczinBKDOVPWJlieffHI0NjYWrlb27t1buKr5SFNTUzQ1NR3+QgDqUlVXMMcee2wsWLAgNm/ePOz45s2b44ILLjiqwwCob1VdwURErFy5Mm644YZYuHBhnH/++dHZ2Rm7d++OZcuWZewDoE5VHZivfOUr8c9//jPuv//++Nvf/hZz586NX/3qVzF9+vSMfQDUqap/DuZI+TkYKIefgxkZPwdzaGk/BwMAIyUwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUlT9ZpdjVS2+J9LFF19c9oSCv/71r2VPKHjzzTfLnlAwODhY9oSC008/vewJBR//+PVasHPnzrInFNTSpkqlEv39/SO6rysYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0CK8WWevKGhoczTD3PxxReXPaFg9erVZU8oeOedd8qeULBu3bqyJxTs27ev7AkFX//618ueUHDWWWeVPaHg2WefLXtCwe7du8ueMGRwcDD27Nkzovu6ggEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApqgpMe3t7nHvuudHc3Bytra2xdOnSeOONN7K2AVDHqgrMli1boq2tLV566aXYvHlzHDx4MJYsWRL79+/P2gdAnarqA8d+/etfD/v1448/Hq2trdHV1RUXXXTRUR0GQH07ok+07O3tjYiIk0466RPv09/fH/39/UO/7uvrO5JTAlAnDvtF/kqlEitXrozFixfH3LlzP/F+7e3t0dLSMnSbNm3a4Z4SgDpy2IG59dZb47XXXosnn3zykPdbtWpV9Pb2Dt16enoO95QA1JHD+hLZbbfdFps2bYqtW7fGqaeeesj7NjU1RVNT02GNA6B+VRWYSqUSt912Wzz99NPx/PPPx4wZM7J2AVDnqgpMW1tbbNiwIZ555plobm6OPXv2RERES0tLTJw4MWUgAPWpqtdgOjo6ore3Ny6++OI45ZRThm4bN27M2gdAnar6S2QAMBLeiwyAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEgxRF9ZPJY8uqrr5Y9oaC7u7vsCQUXXnhh2RMK1q5dW/aEgoaGhrInFEyePLnsCQVdXV1lTyh45plnyp5Q8Pe//73sCUOqeU9KVzAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBTjyzx5pVIp8/TD7Nmzp+wJBQ899FDZEwo+97nPlT2hYNGiRWVPKBg3rvb+323btm1lTyh44IEHyp5Q0NXVVfaEgoGBgbInHJba+1sAwJggMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQIojCkx7e3s0NDTEihUrjtIcAMaKww7M9u3bo7OzM84666yjuQeAMeKwAvPBBx/EddddF4899lh85jOfOdqbABgDDiswbW1tccUVV8Sll176X+/b398ffX19w24AjH1Vf2TyU089Fd3d3bF9+/YR3b+9vT3uu+++qocBUN+quoLp6emJ5cuXxxNPPBETJkwY0WNWrVoVvb29Q7eenp7DGgpAfanqCqarqyv27t0bCxYsGDo2MDAQW7dujUceeST6+/ujsbFx2GOampqiqanp6KwFoG5UFZhLLrkkXn/99WHHbrrpppg1a1bcddddhbgA8OlVVWCam5tj7ty5w44df/zxMXny5MJxAD7d/CQ/ACmq/i6yj3v++eePwgwAxhpXMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApjvi9yMaKceNqr7Xz588ve0JBa2tr2RMKPvjgg7InFBxzzDFlTyioxT/jM2fOLHtCwWuvvVb2hIKDBw+WPeGw1N6fOADGBIEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASDG+7AG1YubMmWVPKLjsssvKnlDQ2NhY9oSCn/zkJ2VPKDj55JPLnlBw3nnnlT2hYOXKlWVPKNizZ0/ZEwq2bNlS9oQhlUolKpXKiO7rCgaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkqDow77zzTlx//fUxefLkOO644+Kcc86Jrq6ujG0A1LGqPg/m/fffj0WLFsUXvvCFePbZZ6O1tTX+8pe/xIknnpg0D4B6VVVg1q5dG9OmTYvHH3986Njpp59+tDcBMAZU9SWyTZs2xcKFC+Pqq6+O1tbWmDdvXjz22GOHfEx/f3/09fUNuwEw9lUVmLfeeis6Ojris5/9bPzmN7+JZcuWxe233x4//elPP/Ex7e3t0dLSMnSbNm3aEY8GoPZVFZjBwcGYP39+rFmzJubNmxe33HJLfO1rX4uOjo5PfMyqVauit7d36NbT03PEowGofVUF5pRTTokzzjhj2LHZs2fH7t27P/ExTU1NMWnSpGE3AMa+qgKzaNGieOONN4Yd27VrV0yfPv2ojgKg/lUVmDvuuCNeeumlWLNmTbz55puxYcOG6OzsjLa2tqx9ANSpqgJz7rnnxtNPPx1PPvlkzJ07N7773e/GQw89FNddd13WPgDqVFU/BxMRceWVV8aVV16ZsQWAMcR7kQGQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQE
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(x_small, cmap = 'gray');"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "3aebbb19",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAGdCAYAAAAv9mXmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVYUlEQVR4nO3de2idhf3H8W8a9bR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BCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQ4rMgnb2hoKPLphznnnHOKnlDh+9//ftETKrzzzjtFT6jQ0dFR9IQKe/bsKXpChauvvrroCRXmzJlT9IQKnZ2dRU+o0NPTU/SEIYODg/Huu++O6L7OYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0CKqgLT1tYWixYtiqampmhpaYkVK1bEa6+9lrUNgDpWVWC2bNkSra2t8dxzz0VnZ2fs27cvli9fHh9++GHWPgDqVFUfOPbb3/522D8/8MAD0dLSEl1dXXHmmWce0mEA1LeD+kTL3t7eiIg49thjP/E+/f390d/fP/TPfX19B/OUANSJA36Tv1wux5o1a2LZsmX7/djTtra2aG5uHrpNnTr1QJ8SgDpywIFZuXJlvPzyy/Hwww/v935r166N3t7eoVstfbY0AHkO6Ftk1113XWzevDm2bt0aJ5544n7vWyqVolQqHdA4AOpXVYEpl8tx3XXXxaOPPhpPPfVUzJgxI2sXAHWuqsC0trbGxo0b47HHHoumpqbYtWtXREQ0NzfHhAkTUgYCUJ+qeg+mvb09ent744tf/GKccMIJQ7dNmzZl7QOgTlX9LTIAGAnXIgMghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIcVAfmTyWvPLKK0VPqNDd3V30hApLliwpekKFdevWFT2hwrhxtfd3t/19tHlRtm/fXvSECo8//njREyrs3r276AlDqrkmZe19FQAwJggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQIrDinzycrlc5NMP8+677xY9ocI999xT9IQKn/vc54qeUGHx4sVFT6gwblzt/d3t2WefLXpChR/96EdFT6jQ3d1d9IQKAwMDRU84ILX3VQDAmCAwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNAioMKTFtbWzQ0NMTq1asP0RwAxooDDsy2bduio6MjTj311EO5B4Ax4oAC88EHH8Sll14a999/f3zmM5851JsAGAMOKDCtra1x/vnnx9lnn/1f79vf3x99fX3DbgCMfVV/ZPIjjzwSL774Ymzbtm1E929ra4vbbrut6mEA1LeqzmB6enpi1apV8dBDD8X48eNH9Ji1a9dGb2/v0K2np+eAhgJQX6o6g+nq6ordu3fHggULho4NDAzE1q1b4+67747+/v5obGwc9phSqRSlUunQrAWgblQVmLPOOiteeeWVYceuvPLKmDlzZtx0000VcQHg06uqwDQ1NcWcOXOGHTvqqKNi0qRJFccB+HTzm/wApKj6p8j+3VNPPXUIZgAw1jiDASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEhx0NciGyvGjau91p566qlFT6hw/PHHFz2hwgcffFD0hAqHH3540RMq1OL/45/97GeLnlDh1VdfLXpChX379hU94YDU3v9xAIwJAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQQmAASCEwAKQQGABSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQ4rCiB9SKk046qegJFc4555yiJ1RobGwsekKFX/ziF0VPqDBp0qSiJ1RYtGhR0RMqrFy5sugJFXbt2lX0hApPP/100ROGlMvlKJfLI7qvMxgAUggMACkEBoAUAgNACoEBIIXAAJBCYABIITAApBAYAFIIDAApBAaAFAIDQAqBASCFwACQourAvPXWW3HZZZfFpEmT4sgjj4zTTjsturq6MrYBUMeq+jyY999/P5YuXRpf+tKX4oknnoiWlpZ4/fXX45hjjkmaB0C9qiowt99+e0ydOjUeeOCBoWO1+EFdABSvqm+Rbd68ORYuXBgXXXRRtLS0xLx58+L+++/f72P6+/ujr69v2A2Asa+qwLzxxhvR3t4en//85+N3v/tdXHvttXH99dfv9yNr29raorm5eeg2derUgx4NQO2rKjCDg4Mxf/782LBhQ8ybNy+uueaa+OY3vxnt7e2f+Ji1a9dGb2/v0K2np+egRwNQ+6oKzAknnBCnnHLKsGOzZs2KnTt3fuJjSqVSTJw4cdgNgLGvqsAsXbo0XnvttWHHduzYEdOnTz+kowCof1UF5oYbbojnnnsuNmzYEH/9619j48aN0dHREa2trVn7AKhTVQVm0aJF8eijj8bDDz8cc+bMiR/84Adx5513xqWXXpq1D4A6VdXvwUREXHDBBXHBBRdkbAFgDHEtMgBSCAwAKQQGgBQCA0AKgQEghcAAkEJgAEghMACkEBg
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x_small[1, 1] = 255\n",
"plt.imshow(x_small, cmap = 'gray');"
]
},
{
"cell_type": "markdown",
"id": "14278fd3",
"metadata": {},
"source": [
"Przycinanie odbywa się przez znany w Pythonie tzw. *slicing*, czyli wycinki:"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "52b49c59",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhYAAAFhCAYAAAAsiOM3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAU4klEQVR4nO3df6yWdf3H8feBAzeoh5NgEGccjNRERcg45g5imT/YzhjTtZltRpT5x8mDQWdthv5hNfO4tlw28qxjRjpnsFaobQGeloDOseDoSYbNdLo4pcR0eQ6wdZuH6/uXZ19CtBs/9/3hcB6P7dq8b+6z63UJwtPr3IdTVxRFEQA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223RVtbWzQ3N8eBAwdi/fr1sXXr1ti8eXO19gEAo0hFYfHPf/4zli9fHq+//no0NjbG/PnzY/PmzXH11VdXax8AMIpUFBYPPPBAtXYAACcB3ysEAEhGWAAAyQgLACAZYQEAJCMsAIBkhAUAkIywAACSERYAQDLCAgBIRlgAAMkICwAgGWEBACQjLACAZIQFAJCMsAAAkhEWAEAywgIASEZYAADJCAsAIBlhAQAkIywAgGSEBQCQjLAAAJIRFgBAMvW5TvznP/85SqVSrtNn0d/fn3tCFg8++GDuCVlMmDAh94Qs2tvbc0/IYvHixbknZDFp0qTcE7Koq6vLPSGLoig+8DXuWAAAyQgLACAZYQEAJCMsAIBkhAUAkIywAACSERYAQDLCAgBIRlgAAMkICwAgGWEBACQ
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(x_small[3:8, 2:], cmap = 'gray');"
]
},
{
"cell_type": "markdown",
"id": "e191d0e8",
"metadata": {},
"source": [
"Możemy również ustawić kolor dla kilku kanałów jednocześnie dla zadanego regionu. Wykonamy to na kopii obrazu:"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "94db5076",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Sa9tW5bfh/1muapdneIW774XVWZSJA0KlpkCBBlgV4DckeSOWuwT2SKyRYItspPfgIT5Ddh0h51sEiBgyYJkIE2KQUZG8cp7yl2satZqzB1ByRTEgC0zIsA7gIOHe7DfOfusvdYcc45/JUophU/1qT7Vp/pUn+q3uORv+g18qk/1qT7Vp/pU/7b61Kw+1af6VJ/qU/3W16dm9ak+1af6VJ/qt74+NatP9ak+1af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nb0PdvkaawuifW5ZnpfOTzDweMsWy3BiklpfSEGJmXmXbY8Nn7d8zTwvl0YRpHpvPIt998B0UiiyaHwrv3n9O3G7775pFljrx7/xmH3R0ICN7hlkRYC0PboETLPE+8vF7Ybd7QNVu8v2B0x/c+/wGP3z2zTgHvIsFPFAQueHyKJAqqsXTtljxA9jCnhegzX375DffvIjf3d9iu5+b2nrCuDF3HMGzZ7Q5oodjtXpnHhcv5zHffPfG9Dz/i6eWZb777jvHiUKpjt9uz2e3Z7vcoY1jdyryuLOtCj2C32XG+TNi240e/9/t8+bOf4/xMihFKRgqBup4yBFAKrHnEGotSGmky6/mC8LGeNZuWfT+QCpzHkWWeWZ3DNi1v7+8xTYM
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"image_edited = image.copy()\n",
"image_edited[100:200, 150:250] = (128, 0, 128)\n",
"plt.imshow(image_edited[..., ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "f340e7ec",
"metadata": {},
"source": [
"Przeskalowanie obrazu odbywa się przez [`cv.resize()`](https://docs.opencv.org/4.5.3/da/d54/group__imgproc__transform.html#ga47a974309e9102f5f08231edc7e7529d), w której albo podajemy dokładne docelowe wymiary, albo podajemy współczynniki skalowania na osiach *x* i *y*; możemy też uwzględnić odpowiednią metodę interpolacji. Matplotlib nie wyświetli nam wprost powiększonych obrazków, ale będziemy mogli zauważyć zmianę poprzez np. poprzez zmianę zakresów skali osi *x* i *y*:"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "fda0546a",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaEAAAGeCAYAAAA9hL66AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAp10lEQVR4nO3df2xUVf7/8VeBdijQ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WSReu3FxUVKSDBw/2+m+6urp6rKps/eUvAGDg65ePcGRlZfX4exAEF9x3XnV1taLRaPJWUlLSH0MCAGQgp03o/Mc3z18Rndfa2nrRfW1WrFih9vb25K25udnlkAAAGcxpEyorK1MsFlNtbW3yvu7ubtXX12vmzJm9/ptIJKL8/PweNwDA0JDy74ROnjypb775Jvn3pqYm7dmzRwUFBbr66qu1bNkyrVq1ShMnTtTEiRO1atUqjRo1Sg8//LDTgQMABr6Um9DOnTs1e/bs5N+XL18uSVq4cKH+9a9/6emnn9bp06f1xBNP6Pjx45oxY4Y+/fRT0za9rllTu5YEv2WLXUuS2rINr7XOUmPJZ1nGLV34u77eWJLillUcrOeLJQlvGZMlKX/69GnTmCwrJriqsawoINlW17DUjB07NrTGuoqD5XWx1Fjev5ZVUSTb+8Wy9XxbW5uTGsn2YS3L94KffwDsYlxt753KigkpN6FZs2Zd8gmysrJUVVWlqqqqVA8NABhiBuYCRwCAQYEmBADwhiYEAPCGJgQA8IYmBADwhiYEAPCGJgQA8GZQb+9tCftJtoCWJeg
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x_small_resized_1 = cv.resize(x_small, (40, 40))\n",
"plt.imshow(x_small_resized_1, cmap='gray');"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "e85d632e",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAUQAAAGeCAYAAADsT3iPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAlR0lEQVR4nO3dfWyV9fnH8c8p0EPpw0Es7TmVUjsEnYAkiuMhylOkocuICFlQEwN/jPgAJAQXHZDNbpmUkEhcwsY2ZxgkMvhjoiYwsAu2zJAmhWBs0DjUAlVaCpU+UKAVuH9/7Mv5W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ln5eX51li2qu/t98nXGjp0qG+NZfWMdQVRUJcQsKxEsnxvUnCXibCs6Dl//rypJ8tMsaXG8njWy034rdaxrlRJOBBnzJhxwzsPhUIqKytTWVlZoncNAEnF5g4A4BCIAOAQiADgEIgA4BCIAOAQiADgEIgA4NzxlxAIaptyy/C2ZShZsg2ttra2+tZYtpe3DkFbhrwtw9uW4eZwOGzqyTJwbBnMzsjIMD3e3Xff7VtjGbq2LEKwDFxLttfmD3eL6o3l9XT69GlTT6dOnfKtOXPmjG/NuXPnfGss35vkP8DdZ5cQAIA7FYEIAA6BCAAOgQgADoEIAA6BCAAOgQgADoEIAM4dP5htGUy21FgGs607DluGVq+9UFdPLAPO1t2iBwwY4FtjGThOS/P/P9a6e7rfLsiSbTDbOgRt6ctSY3leLK8nyTbs/9133/nWnDx50rfm22+/NfXU0NDgW2N5jVsWKFh2vJfsx9MPZ4gA4BCIAOAQiAD
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x_small_resized_2 = cv.resize(x_small, None, fx=3, fy=4, interpolation=cv.INTER_CUBIC)\n",
"plt.imshow(x_small_resized_2, cmap='gray');"
]
},
{
"cell_type": "markdown",
"id": "09a01036",
"metadata": {},
"source": [
"Obrót obrazu dokonywany jest przez funkcję [`cv.flip()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#gaca7be533e3dac7feb70fc60635adf441), w której podajemy według której osi ma nastąpić obrót (`0`: *x*, `1`: *y*, `-1`: obie)."
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "fd673085",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9y69lW5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EUHEgwvj/bwldYqIQ3sf77UwJcV7b5VUx6oVBe2d2zcKQgoLTqzqsg9wvaO100pDvAUOP74fEWL3+Cpo72ju1FpZny84IDih7JkwCVIqrjRiU6IEmgsoHqcOrwLOQ9NxGUS0ZwLeKl8ntFbRrnT6uKBG5us9Ta0abbmhtVow60pXUMSyWwScw7kA4l6DMCpobQQ8UR3SlFwKPkREOk0tcHZ72a2qc84CCmqVmN4qiU6MR0oReleEBKJ4n3CCJU1qlUdMDidW1aoqTgLeTXgXoVfQAN0jGnFiz8MSUasW857Z99WCkOs46dAyxykxpYRD2M6ZII7gEiFFQ0N65+P6bBVmgyiC9w6nigtCdEqgIMERvCOpEDKU3qldmYKQQ6AUQbugEhGnNCrRRdvTapV6ip7eilX16klhpgePRxEfCSHhXEAbeAl4cbTSqBScBHptaFe7k2LC4QkhEVMit0Zrja72HolzlliMdFmcA+/wcyK4AN4CihO7Nxvgxxu6pAm6knOm5ELdC6LQA6h4utqb731ARehOaNqp4/NObJ867w3hwd4vHwWi4J0fVbsFzd6a7eLWv/d9/2uDAf/gD/6Av/t3/y5/+S//Zf7qX/2r/PN//s/56U9/yt/7e3/ve/+M2hsl7/gYDbYpBUFxrkOAWnfYKjE
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"image_flipped = cv.flip(image, 0)\n",
"plt.imshow(image_flipped[..., ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "e4c0f0d8",
"metadata": {},
"source": [
"Może pojawić się potrzeba utworzenia nowych obrazów, więc najczęściej używa się do tego biblioteki NumPy:"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "fc86f294",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "markdown",
"id": "bc67f439",
"metadata": {},
"source": [
"Poniższe wywołania pokazują kilka wariantów. Możemy utworzyć pustą trójwymiarową macierz wypełnioną zerami przy pomocy [`numpy.zeros()`](https://numpy.org/doc/stable/reference/generated/numpy.zeros.html):"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "a8cb1c58",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAEmCAYAAADCwPIpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVXUlEQVR4nO3df2zdVf348ddlY3c/aK/8CL2rG7OLjfyYU9iQMCdbhNXoYiQkBhk/ZvwL2HB1icDAZJNIu8xkQTPZwjTEBHHGOBSNEqpAkSxIGanULQGJdTSy2qB4W35sC+v5/vH5cmPdgHVrT9vxeCTnj5736e1hh6XPvHvfayGllAIAIJNTxnoDAMAHi/gAALISHwBAVuIDAMhKfAAAWYkPACAr8QEAZCU+AICsxAcAkJX4AACymjxaL3zvvffGd7/73di/f39ccMEFcc8998RnPvOZ9/28wcHBeOWVV6KmpiYKhcJobQ8AGEEppRgYGIj6+vo45ZT3ubeRRsGOHTvSqaeemrZv35727t2b1qxZk2bMmJH27dv3vp/b09OTIsIwDMMwjAk4enp63vd7fSGlkf/FcpdccklcdNFFsXXr1urceeedF1deeWW0tra+5+dWKpX40Ic+NNJbAgAy+M9//hOlUuk914z4ez4OHToUu3fvjqampiHzTU1NsWvXriPWHzx4MPr7+6tjYGBgpLcEAGRyLG+ZGPH4ePXVV+Pw4cNRV1c3ZL6uri56e3uPWN/a2hqlUqk6Zs+ePdJbAgDGkVF72uV/yyeldNQaWrduXVQqlero6ekZrS0BAOPAiD/tctZZZ8WkSZOOuMvR19d3xN2QiIhisRjFYnGktwEAjFMjfudjypQpsWDBgmhraxsy39bWFosWLRrpLwcATDCj8u98rF27Nq6//vpYuHBhXHrppXHffffFyy+/HDfeeONofDkAYAIZlfi4+uqr41//+lfcddddsX///pg3b1789re/jTlz5ozGlwMAJpBR+Xc+TkR/f//7Ph8MAI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zJo1KzZu3BjPPvtsPPvss/HZz342vvSlL1UDY9OmTbF58+bYsmVLdHR0RLlcjmXLlsXAwMCobB4AmIDSCTr99NPTD3/4wzQ4OJjK5XLauHFj9dqBAwdSqVRK27ZtO+bXq1QqKSIMwzAMw5iAo1KpvO/3+uN+z8fhw4djx44d8cYbb8Sll14a3d3d0dvbG01NTdU1xWIxlixZErt27XrX1zl48GD09/cPGQDAyWvY8dHV1RWnnXZaFIvFuPHGG+Ohhx6K888/P3p7eyMioq6ubsj6urq66rWjaW1tjVKpVB2zZ88e7pYAgAlk2PHxsY99LDo7O+Ppp5+Om266KVauXBl79+6tXi8UCkPWp5SOmPtv69ati0qlUh09PT3D3RIAMIFMHu4nTJkyJT760Y9GRMTChQujo6Mjvve978Vtt90WERG9vb0xc+bM6vq+vr4j7ob8t2KxGMVicbjbAAAmqBP+dz5SSnHw4MFoaGiIcrkcbW1t1WuHDh2K9vb2WLRo0Yl+GQDgJDGsOx933HFHfP7zn4/Zs2fHwMBA7NixI5544ol45JFHolAoRHNzc7S0tERjY2M0NjZGS0tLTJ8+PVasWDFa+wcAJphhxcc///nPuP7662P//v1RKpVi/vz58cgjj8SyZcsiIuLWW2+Nt956K26++eZ47bXX4pJLLolHH300ampqRmXzAMDEU0gppbHexH/r7++PUqk01tsAAI5DpVKJ2tra91zjd7sAAFmJDwAgK/EBAGQlPgCArMQHAJCV+AAAshIfAEBW4gMAyEp8AABZiQ8AICvxAQBkJT4AgKzEBwCQlfgAALISHwBAVuIDAMhKfAAAWYk
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"image_empty = np.zeros((50, 100, 3), dtype='uint8')\n",
"plt.imshow(image_empty);"
]
},
{
"cell_type": "markdown",
"id": "dde3f2b0",
"metadata": {},
"source": [
"Jeżeli chcemy ustawić jakąś początkową wartość, to możemy przeskalować tablicę jedynek uzyskaną z [`numpy.ones()`](https://numpy.org/doc/stable/reference/generated/numpy.ones.html):"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "7190f1df",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec78b490>"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAEmCAYAAADCwPIpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVxUlEQVR4nO3df2zUdx3H8ddBx7ctXE+BcEelYImdbKvoRieh4lrdqGFkkTQxczDG4j9jhdmORCjDZHWRXoMJVlOHgRgkwVpjREWjpNW54tIgpUtdLQlzsbLTcTZTvJZf14x+/MPwzW5lbMeu797B85F8/7jP93PtZ3zW9Jnvfa8XcM45AQAAGJk21QsAAAC3FuIDAACYIj4AAIAp4gMAAJgiPgAAgCniAwAAmCI+AACAKeIDAACYIj4AAIAp4gMAAJjKm6wv/Pzzz+tb3/qWzp49q7vuukutra367Gc/+57PGx8f1xtvvKFgMKhAIDBZywMAABnknNPo6KiKi4s1bdp7XNtwk6Cjo8Pddtttbv/+/e7UqVOuvr7ezZw50505c+Y9nxuLxZwkDg4ODg4Ojhw8YrHYe/6uDziX+Q+WW758ue655x7t3bvXH7vjjju0du1aRaPR6z43kUjoQx/6kJ5++ml5npfppQEAgEmQTCb17W9/W//9738VCoWuOzfjL7uMjY2pr69PjY2NKeM1NTXq6emZMD+ZTCqZTPqPR0dHJUme5yk/Pz/TywMAAJPo/dwykfEbTt98801duXJF4XA4ZTwcDisej0+YH41GFQqF/KOkpCTTSwIAAFlk0t7t8s7ycc5ds4Z27NihRCLhH7FYbLKWBAAAskDGX3aZO3eupk+fPuEqx/Dw8ISrIdL/X17h3g4AAG4dGb/yMWPGDC1btkxdXV0p411dXaqsrMz0twMAADlmUv7Ox9atW7V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8QEAAEwRHwAAwBTxAQAATBEfAADAFPEBAABMER8AAMAU8QEAAEwRHwAAwBTxAQAATBEfAADAFPEBAABMER8AAMAU8QEAAEwRHwAAwBTxAQAATBEfAADAFPEBAABMER8AAMAU8QEAAEwRHwAAwBTxAQAATBEfAADAVFrxsXfvXi1dulRFRUUqKirSihUr9Nvf/tY/75xTU1OTiouLVVBQoOrqag0ODmZ80QAAIHelFR8LFixQS0uLTp48qZMnT+rzn/+8vvjFL/qBsXv3bu3Zs0dtbW3q7e1VJBLRqlWrNDo6OimLBwAAuSet+HjooYf04IMP6vbbb9ftt9+uXbt2adasWTp+/Licc2ptbdXOnTtVW1ur8vJyHTx4UBcvXlR7e/tkrR8AAOSYG77n48qVK+ro6NCFCxe0YsUKDQ0NKR6Pq6amxp/jeZ6qqqrU09Pzrl8nmUxqZGQk5QAAADevtONjYGBAs2bNkud52rRpk37+85/rzjvvVDwelySFw+GU+eFw2D93LdFoVKFQyD9KSkrSXRIAAMghacfHxz/+cfX39+v48eN68skntXHjRp06dco/HwgEUuY75yaMvd2OHTuUSCT8IxaLpbskAACQQ/LSfcKMGTP0sY99TJJUUVGh3t5efec739H27dslSfF4XPPnz/fnDw8PT7ga8nae58nzvHSXAQAActQH/jsfzjklk0mVlpYqEomoq6vLPzc2Nqbu7m5VVlZ+0G8DAABuEmld+XjmmWe0evVqlZSUaHR0VB0dHXrxxRd19OhRBQIBNTQ0qLm5WWVlZSorK1Nzc7MKCwu1bt26yVo/AADIMWnFx7/+9S9t2LBBZ8+eVSgU0tKlS3X06FGtWrVKkrRt2zZdunRJdXV1OnfunJYvX67Ozk4Fg8FJWTwAAMg9Aeecm+pFvN3IyIhCoZAaGxuVn58/1csBAADvw+XLl9X
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"image_empty = 128*np.ones((50, 100, 3), dtype='uint8')\n",
"plt.imshow(image_empty)"
]
},
{
"cell_type": "markdown",
"id": "4f785c86",
"metadata": {},
"source": [
"Jeżeli nowy obraz powinien mieć takie same wymiary jak inny obraz, to możemy do tej operacji użyć [`numpy.ones_like()`](https://numpy.org/doc/stable/reference/generated/numpy.ones_like.html):"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "0f99dda7",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAb9UlEQVR4nO3de2xUZf7H8c/Qy1ibdkKpnYuUptlgdtc2JBYXbFTu1SaFRcyCmmwgISautElTiBHNxrrZUEIi7B9dMWsMiJct/1A1gaA1QLVpSLCLEVhDaqxSTCeNbJlpsU6hPL8/fvHE4SaF1vl2+n4lJ2HOeWb6PGcm8/Z0Zrs+55wTAACGTUv1BAAA+CXECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGBeSmP16quvqrS0VHfccYcqKir06aefpnI6AACjUharvXv3qr6+Xi+++KKOHz+uhx56SNXV1Tpz5kyqpgQAMMqXqj9kO2/ePN13333auXOnt+93v/udVq5cqaamplRMCQBgVGYqfujIyIi6urr0/PPPJ+2vqqpSZ2fnVeMTiYQSiYR3+/Lly/rf//6nGTNmyOfzTfh8AQDjzzmnwcFBRSIRTZt241/0pSRW33//vUZHRxUMBpP2B4NBRaPRq8Y3NTXp5Zdf/rWmBwD4FfX29mrmzJk3HJOSWP3kyqsi59w1r5Q2b96shoYG73YsFtOsWbPU29ur/Pz8CZ8nAGD8xeNxFRcXKy8v7xfHpiRWhYWFysjIuOoqqr+//6qrLUny+/3y+/1X7c/PzydWADDJ3czHOSn5NmB2drYqKirU1taWtL+trU2VlZWpmBIAwLCU/RqwoaFBf/7znzV37lw98MAD+te//qUzZ87omWeeSdWUAABGpSxWa9as0blz5/S3v/1NfX19Kisr04EDB1RSUpKqKQEAjErZ/87qdsTjcQUCAcViMT6zAoBJaizv5fxtQACAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnjHqvGxkb5fL6kLRQKecedc2psbFQkElFOTo4WLlyoU6dOjfc0AABpZEKurO6991719fV524kTJ7xj27Zt0/bt29Xc3Kxjx44pFApp2bJlGhwcnIipAADSwITEKjMzU6FQyNvuuusuSf9/VfWPf/xDL774olatWqWysjK9+eab+uGHH/Tuu+9OxFQAAGlgQmLV3d2tSCSi0tJSPfHEE/r6668lST09PYpGo6qqqvLG+v1+LViwQJ2dndd9vEQioXg8nrQBAKaOcY/VvHnztGfPHn344Yd6/fXXFY1GVVlZqXPnzikajUqSgsFg0n2CwaB37FqampoUCAS8rbi4eLynDQAwbNxjVV1drccff1zl5eVaunSp9u/fL0l68803vTE+ny/pPs65q/b93ObNmxWLxbytt7d3vKcNADBswr+6npubq/LycnV3d3vfCrzyKqq/v/+qq62f8/v9ys/PT9oAAFPHhMcqkUjoyy+/VDgcVmlpqUKhkNra2rzjIyMjam9vV2Vl5URPBQAwSWWO9wNu2rRJy5cv16xZs9Tf36+///3visfjWrt2rXw+n+rr67VlyxbNnj1bs2fP1pYtW3TnnXfqqaeeGu+pAADSxLjH6uzZs3ryySf1/fff66677tL8+fN19OhRlZSUSJKee+45DQ8P69lnn9XAwIDmzZunjz76SHl5eeM9FQBAmvA551yqJzFW8XhcgUBAsViMz68AYJ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AwoHnz5umjjz5SXl6ed58dO3YoMzNTq1ev1vDwsJYsWaLdu3crIyNjHJYEAEg3PuecS/UkxioejysQCCgWi/ErQQCYpMbyXs7fBgQAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJhHrAAA5hErAIB5xAoAYB6xAgCYR6wAAOYRKwCAecQKAGAesQIAmEesAADmESsAgHnECgBgHrECAJg35lh98sknWr58uSKRiHw+n957772k4+vWrZPP50va5s+fnzQmkUiorq5OhYWFys3N1YoVK3T27NnbWggAIH2NOVYXLlzQnDlz1NzcfN0xjz76qPr6+rztwIEDScfr6+vV2tqqlpYWdXR0aGhoSDU1NRodHR37CgAAaS9zrHeorq5WdXX1Dcf4/X6FQqFrHovFYnrjjTf01ltvaenSpZKkt99+W8XFxfr444/1yCOPjHVKAIA0NyGfWR05ckRFRUW655579PTTT6u/v9871tXVpYsXL6qqqsrbF4lEVFZWps7OzomYDgBgkhvzldUvqa6u1p/+9CeVlJSop6dHf/3rX7V48WJ1dXXJ7/crGo0qOztb06dPT7pfMBhUNBq95mMmEgklEgnvdjweH+9pAwAMG/dYrVmzxvt3WVmZ5s6dq5KSEu3fv1+rVq267v2cc/L5fNc81tTUpJdffnm8pwoAmCQ
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"empty_from_other = 255*np.ones_like(image)\n",
"plt.imshow(empty_from_other);"
]
},
{
"cell_type": "markdown",
"id": "ac02a038",
"metadata": {},
"source": [
"Czasami może być przydatne utworzenie maski zawierającej informację o tym czy np. dany piksel zawiera wartość w danym zakresie. Przy pomocy [`cv.inRange()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#ga48af0ab51e36436c5d04340e036ce981) możemy sprawdzić zakresy dla trzech kanałów; przy okazji możemy zobaczyć jak zgrupować kilka obrazów jednocześnie (por. [`matplotlib.pyplot.subplot()`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplot.html)):"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "d536f6e6",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAz8AAAGfCAYAAABx1myEAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9d7Bta1rQ/37fNOJMK+x8QgdAu0GgAAW8v76AIqUiaisWSilJBWmkCAUWFFUkC5F4TUSlUcBYoJaCgSZIISi2YpNpmqZP6HN2WGmGEd94/xibc399T7e/Bro5Hcbn1K69z1xjjTnmmnONdzzjfZ7nFSmlxGw2m81ms9lsNpu9h5Mv9AHMZrPZbDabzWaz2e+GOfiZzWaz2Ww2m81m7xXm4Gc2m81ms9lsNpu9V5iDn9lsNpvNZrPZbPZeYQ5+ZrPZbDabzWaz2XuFOfiZzWaz2Ww2m81m7xXm4Gc2m81ms9lsNpu9V5iDn9lsNpvNZrPZbPZeYQ5+ZrPZbDabzWaz2XuFOfiZvdf7x//4HyOEeIs/165d46M/+qP5wR/8wd/WPl/0ohfxJ/7En3gHH+lsNpvNZv8///fx67/8l//yvK+nlHif93kfhBB89Ed/9Dv8+Z944gmEEHzjN37jO3zfs9k7yxz8zGYPffd3fzf/7b/9N376p3+a7/zO70QpxSd8wifw7//9v3+hD202m81ms7dpuVzyXd/1Xc97/Cd+4id44xvfyHK5fAGOajZ71zQHP7PZQx/wAR/AR3zER/CRH/mRvPKVr+QHf/AHyfOcf/7P//kLfWiz2Ww2m71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ure size 1000x1000 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"mask = cv.inRange(image, (0,100,150), (100,150,200))\n",
"\n",
"plt.figure(figsize=[10,10])\n",
"plt.subplot(121)\n",
"plt.imshow(image[..., ::-1])\n",
"plt.title(\"Baboon\")\n",
"plt.subplot(122)\n",
"plt.imshow(mask, cmap='gray')\n",
"plt.title(\"Mask\");"
]
},
{
"cell_type": "markdown",
"id": "622a0f0d",
"metadata": {},
"source": [
"Standardowo operujemy w zakresie liczb całkowitych `[0; 255]`, przez co jeśli w wyniku jakiejś operacji mielibyśmy wykroczyć poza zakres, to skończy się to albo operacją modulo albo np. uzyskaniem wartości ujemnych, co ostatecznie przełoży się na błędny wynik.\n",
"\n",
"Załóżmy, że chcemy podbić kontrast o 50%. Przemnożenie obrazu o wartość 1.5 zwróci nam tablicę o wartościach liczb rzeczywistych:"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "d48cf055",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"float64\n"
]
}
],
"source": [
"new_image = image * 1.5\n",
"print(new_image.dtype)"
]
},
{
"cell_type": "markdown",
"id": "b2dbeacc",
"metadata": {},
"source": [
"W takim wypadku możemy naiwnie spróbować przekonwertować to ponownie do liczb całkowitych, ale wartości powyżej 255 zostaną obliczone według operacji modulo, przez co wynik będzie niezadowalający:"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "411dabb9",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9d7Bt3V2eiT5jjpnnXHntfMJ3zne+HBSRhI1ANklgjMgIEYwxFLLAJGMuNAYbOYDtxqaNDTZug3E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F0t8KyAMXIKFw0KGRE0BqqSOG4YDwVvebPOZn7Hmr77+hPe+b8b3/E+Ps7O1ZjAs6bqctKhZfm2FMQ1OAePRmOH2lNlJStfaRP6Qb/3rM24dPE/Y8wniCePNTWSSkeWKrrPplE2nWrpWo7XGsgyeI1icHRN420R+SH9rl37m0EzH+FFHpxJu3bpLVQv8wEdYFsJyEZZLVWUEQcSlvas8/sgrgD8duPwf8TERK9d1eclLXsJv/MZv8IVf+IV/cv03fuM3eM1rXvNRv8+4v0EUGZJkQVPW7O4GSFfQGkNedYztHk4ETWMQliaMPfzeBM+b4DrgSkOarNCNgq4FXXN6ekgcdexd2aTvxNC1VNWahx6+ymJ1yjq7yc+/eYUTVvieQ6dBeppHHr3O/dc9louCxXxNWSa8+11/wBv+6mWm0zG27eJLzVNP32S6eZnJxi7dacLR6QJpe/QGY/YuTxgMriNdTZ7vc5YcsDg94pGHtvD9kMnEQ0qJ1gOqtmH91xJ6n23z4GfcYL1MOPu3M5aftGR5NufZZ54DbSO/3KW7CverhxiGY577/tukv9Rw/T88wPb
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"new_image = np.uint8(new_image)\n",
"plt.imshow(new_image[..., ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "1fea50c7",
"metadata": {},
"source": [
"Rozwiązaniem jest przycięcie wartości przy użyciu [`numpy.clip()`](https://numpy.org/doc/stable/reference/generated/numpy.clip.html) do zakresu `[0; 255]` jeśli operujemy na liczbach całkowitych, z ew. znormalizowaniem wartości do zakresu `[0; 1]` jeśli chcemy pracować na liczbach rzeczywistych:"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "eac38489",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90b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nR1z3QimI89jN1TVrfU7Yonj75F1+2xtkHriqLu2NYtzvX4Psxnc6anS1a3BXrwiKIpRb3i9fWXJKOIo+mC+fExKi8pK4PWHtp4aDOgB4u1FikdoS/Y3N8Qh6ekUcL4/Jzx1Gc5m9MPmt0+5+XLN7SdIIojhJQIGSBkQNuWxHHKo4unfOsb/xnw1w8u/0P8UsQqCAK+//3v8wd/8Af8/b//9//q+h/8wR/wd//u3/2Ff898fESaOvJ8Q990nJ/HqEAwOEfVaubeCD+FvncIaUmykGi0IAwXBD4EylHkO2xvQA9gO+7urshSzcWTY8Z+Bnqgbfd89PFTNrs77tZf4b/c4SctUehjHKjQ8o1PnvPiech2U7NZ72manB/82R/z4v3HLJdzxllApCw///QrlsePWRydo+9yru82KC9kNJlz8XjBZPIcFViq6i33+SWbu2u+8dEJUZSwWIQopbB2Qjv07LucUebx4fJ99suc+9WK7XrL9n7N5599AdZDuQDdw4v3P2KazPni81cUec/zFx9wevQIIaFta+pC05aO6SjBlxn7zZ531/csF08ZRQsasyYOxnzy0Xd4/eUl5a6jbTpu2y0OSd021LpnEA4vjhhnS8wMdGPJTUHfaH7y4095/KL
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"new_image = image * 1.5\n",
"clipped_new_image = np.clip(new_image, 0, 255)\n",
"clipped_new_image = np.uint8(clipped_new_image)\n",
"plt.imshow(clipped_new_image[..., ::-1]);"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "bc2cb3df",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Sa9sW3bfi/3mnKteK+qIXZ7innvPrfJmwcykxCf5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dYipSPwBdv7G+LwlCRKGF1cMJ54LGdzBq3Z7XOeP39F2wmiOEJIiZABQgY0bUUcZzx48JhvffpfAX85cPnv45firIIg4Pvf/z6/93u/x9/9u3/3L57/vd/7Pf723/7bv/D7zMcr0hTyfEtf33NxHuMFgsE5ylYz80b4qaDvHVJakiwkHM0JwzmBD4HnKPM9pjegBzAdt7dXpInm8tEpk1mK1gNtm/PJJ4/Z7O+433zF58/3BElLGHoYB17g+OSz93n//YDdtma7yWmaAz/4kz/k/Q8esVzNGY8CImX52c+fsTx5yGJ1gb7Pub7ZoryI8XTGRThnOnkfFRrK6jVl/obd/Q2ffHxKFCUsliFKKawd0w49eZeTZTM+Wn7Afplzv16z2+7Y3m/54udfgPVQzsf0jveffsIknfPlly8o8p73P/iQs+UDhIC2qakKTVs5pqMEX6YctgfeXt+zmj9mFC1o9IY4GPHZJ9/m5ZdvqPYdTd3RtTusk9RdQz30aOHw4ohxtsTOBLp25KagbzQ/+tH
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"new_image = (image * 1.5)/255\n",
"clipped_new_image = np.clip(new_image, 0, 1)\n",
"plt.imshow(clipped_new_image[..., ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "a2f8c4a5",
"metadata": {},
"source": [
"Jeśli zwiększymy jasność i potencjalnie wyjdziemy poza zakres `[0; 255]`, to ponownie wartości zostaną przekręcone:"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "ce823b52",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9y69tW57XiX3Gc77Waz/O455zb9yIyHRlYVFymURC2MKSO0h0DNgNGh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9Xf7sn/2zP/fP2XY7ul6xLCPRn7m+apAaUgmsITPIFt1AjAUhMrY1mHaLMVu0LmgJ6zKTY4KUIAeO52eaJnF9u6cfWlKKeD/z/v0t43Ti5fiB3/vhhLIBYxS5gNKF95++5s0bwzQ6xvOM9ws/+tEPmOdbtrsNfaexsvDV1x/Y7m7Z7q5IZebl5YxQlr4fuLrZ0PevkaawugfW5ZHp9ML7dweMsWy3BiklpfSEGJmXmXbY8MnbN8zTwul4ZhpHptPIN19/C0UiiyaHwpu37+nbDd9+fc8yR968/YTD7gYEBO9wSyKshaFtUKJlnieens/sNq/omi3enzG647P3n3P/7SPrFPAuEvxEQeCCx6dIoqAaS9duyQNkD3NaiD7zxRdfc/smcnV7g+16rq5vCevK0HUMw5bd7oAWit3umXlcOJ9OfPvtA5+9+x4PT498/e23jGeHUh273Z7Nbs92v0cZw+pW5nVlWRd6BLvNjtN5wrYd3/v+r/HFH/wY52dSjFAyUgjU5ZQhgFJgzSPWWJTSSJNZT2eEj/Ws2bTs+4FU4DSOLPPM6hy2aXl9e4t
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"new_image = image + 50\n",
"plt.imshow(new_image[..., ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "4be595c9",
"metadata": {},
"source": [
"Z drugiej strony należy mieć też na uwadze pewne subtelne konwersje, które mogą odbywać się niejawnie. Poniżej mamy operację, która powoduje użycie danych typu `int16`, przez co następuje niejawna konwersja i przycięcie (jest o tym informacja w ostrzeżeniu):"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "c93528a2",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb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QUQo2w4btdsf5vJCjQpqWh6cjH56/pWkNu8OWbrOhrCvrWkhJkgP4kAkhUVKilIQUmdPxGSX3NFZzs9vRDYrdtq4H07Tw8eMj65pRSoHQCKlBaJZ1pm0b7m5v+cH3f5f/8X/4s18Jzvm1NCtrLX/wB3/AP//n/5y/+Tf/5i9//s//+T/nr//1v/4rP86mt2itWZaF6OH2xiJ1IZXEGiKDBN3U05UQYFswLRhTTz9aFtZlJsdUO1iG0wWa5pHb+55+aEgp4v3M55/fMk5njqcP/OmPJ5QNGKPIBZQufP7Fa968MUyjY7zMeL/wk5/8iHm+Z7vb0HcaKwvffDuy3e3Y7gZSmTkeHUIF+r5wc7eh718jTWF1j6zLE9P5yOfvDhhj2W4NUkpK6QkxMi8z7bDhs7dvmKeF8+nCNI5M55Hvvn0PRSKLJofCm7ef07cb3n/7wDJH3rz9jMPuDgQE73BLIqyFoW1QomWeJ55fLuw2r+iaLd5fMLrjy8+/z8P7J9Yp4F0k+ImCwAWPT5FEQTWWrt2SB8gelrSAz3z11bfcv4nc3N9hu56b23vCujJ0HcOwZbc7oIVit3thHhcu5zPv3z/y5bsf8vj8xLfv3zNeHEp17HZ7Nrs92/0eZQyrW5nXlWVd6BHsNjvOlwnbdvzwd36Xr376M5yfSTFCyUghUFKglUIApcCaR6yxKKWRJrOeLwgfyQh007LvB1KB8ziyzDOrc9im5fX9PaZpMMZiBLx784qcC24eWeY
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"new_image = image + (-50)\n",
"plt.imshow(new_image[..., ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "6b3a8f53",
"metadata": {},
"source": [
"Rozwiązaniem powyższych problemów może być w przypadku zmiany jasności użycie funkcji [`cv.add()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#ga10ac1bfb180e2cfda1701d06c24fdbd6) i [`cv.substract()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#gaa0f00d98b4b5edeaeb7b8333b2de353b), a w przypadku zmiany kontrastu użycie [`cv.multiply()`](https://docs.opencv.org/4.5.3/d2/de8/group__core__array.html#ga979d898a58d7f61c53003e162e7ad89f), konwersja do typu np. `float64` i powrót do `uint8` z przycięciem wartości."
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "fba240f9",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Sa+ta7bXif2e8q1mtYpdnL3PiRMR99okFimnuUgIWXSRaAHu0KKPr9xAt2MQDQski28AEt+AL0DnNpGQlWlEWrqmCG7ciDj1XvWc862e2o1nxiHTN5WEbZwRIfaQlo720jxrzfXO9x1jPGP8C1FKKXyMj/ExPsbH+Bi/wSF/3W/gY3yMj/ExPsbH+E/Fx2L1MT7Gx/gYH+M3Pj4Wq4/xMT7Gx/gYv/HxsVh9jI/xMT7Gx/iNj4/F6mN8jI/xMT7Gb3x8LFYf42N8jI/xMX7j42Ox+hgf42N8jI/xGx8fi9XH+Bgf42N8jN/4+FisPsbH+Bgf42P8xsfHYvUxPsbH+Bgf4zc+fq3F6h//43/Mj370I9q25fd+7/f4F//iX/w6387H+Bgf42N8jN/Q+LUVq3/2z/4Zf+fv/B3+/t//+/zrf/2v+ct/+S/zV//qX+WLL774db2lj/ExPsbH+Bi/oSF+XUK2f/Ev/kX+/J//8/yTf/JPvv/en/2zf5a//tf/Ov/oH/2jX8db+hgf42N8jI/xGxr61/FLvff8q3/1r/i7f/fv/o++/1f+yl/hX/7Lf/mnXu+cwzn3/b9zzjw9PXFzc4MQ4v/v7/djfIyP8TE+xn/+KKVwPp959+4dUv7PD/p+LcXq4eGBlBJv3rz5H33/zZs3fPfdd3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[
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"matrix = np.ones(image.shape, dtype='uint8') * 50\n",
"\n",
"image_brighter = cv.add(image, matrix)\n",
"plt.imshow(image_brighter[:, :, ::-1]);"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "79b54cc1",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Sa+lW5rXCf5W+3a7O4011+693kREJhklUpVFICFKxRSJETBilHMUIxQjECOYxDcAiW/AF2DCLFGiUlUhSCkKCic8vLmdmZ1uN2+3+hqs7U5lUcp0VVHp7sIe6ch0jo7ts/e797uetZ5/J0ophU/1qT7Vp/pUn+o3uOSv+wl8qk/1qT7Vp/pU/2v1qVl9qk/1qT7Vp/qNr0/N6lN9qk/1qT7Vb3x9alaf6lN9qk/1qX7j61Oz+lSf6lN9qk/1G1+fmtWn+lSf6lN9qt/4+tSsPtWn+lSf6lP9xtenZvWpPtWn+lSf6je+PjWrT/WpPtWn+lS/8fWpWX2qT/WpPtWn+o2vX2uz+kf/6B/xwx/+kLZt+YM/+AP+xb/4F7/Op/OpPtWn+lSf6je0fm3N6p/+03/K3/k7f4e///f/Pv/6X/9r/spf+Sv8tb/21/j5z3/+63pKn+pTfapP9al+Q0v8uoxs/9Jf+kv8hb/wF/jH//gf//Jnv//7v8/f+Bt/gz/+4z/+dTylT/WpPtWn+lS/oaV/HX/Ue8+/+lf/ir/7d//u/+znf/Wv/lX+5b/8l//J7zvncM798vucM8/Pz9zd3SGE+P/78/1Un+pTfapP9Z+/SilcLhfevXuHlP/Lg75fS7N6fHwkpcSbN2/+Zz9/8+YN79+//09+/4//+I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Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"image_darker = cv.subtract(image, matrix)\n",
"plt.imshow(image_darker[:, :, ::-1]);"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "2fe3e9d5",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Oa+lbbrXCf7u8ZnWWnuKiHfIPBwQLQQSarUACaEWRjsllQVllVV+CQthgbDA4RuAxDdALbWJg9VCwkMYLUqqbh0gx3eIiL33Gp7hntu4nogDfaqrsnqozNSJWwojI+ONWHutZ93X8J9Ua63x5Xw5X86X8+V8Ob/DR/+2X8CX8+V8OV/Ol/Pl/C+dL8Xqy/lyvpwv58v5nT9fitWX8+V8OV/Ol/M7f74Uqy/ny/lyvpwv53f+fClWX86X8+V8OV/O7/z5Uqy+nC/ny/lyvpzf+fOlWH05X86X8+V8Ob/z50ux+nK+nC/ny/lyfufPl2L15Xw5X86X8+X8zp8vxerL+XK+nC/ny/mdP7/VYvVP/+k/5c/9uT9H3/f81b/6V/nX//pf/zZfzpfz5Xw5X86X8zt6fmvF6l/8i3/B3/27f5d/+A//If/u3/07/ubf/Jv81//1f83Pf/7z39ZL+nK+nC/ny/lyfkeP+m0Z2f71v/7X+St/5a/wz/7ZP/v8e3/pL/0l/vbf/tv8k3/yT34bL+nL+XK+nC/ny/kdPfa38Y/GGPm3//bf8vf//t//L37/v/qv/iv+zb/5N3/iz4cQCCF8/t+1Vp6fn3l6ekIp9f/31/vlfDlfzpfz5fz//rTWuF6vfPvtt2j9P7/o+60Uqw8fPlBK4auvvvovfv+rr77i+++//xN//p/8k3/CP/pH/+h/q5f35Xw5X86X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wr8zIT48Y09tAqtRZKSZ8L1DRNGKNYlxmlFLlUnPMMw8jT4xvG6QBKo43Bdx3WWuZ5Zl0XSk48PT7gjAIO+/c7cb69Yp3GeYfvLM5qvPGEEEkhU2Jh6BWHyVDKxrbNxDjz9Pg1OW1AotZIjJktZhoFrWEaB/rDxDxHWlFYO3C+LjyfP+I7y3QcGY4H1BaJsVKqoTVDbYVW9oFCg7WwzFecPeKtoz+d6HrNYZL7YF03np9fyVlhrJNGSRlQlpwjzjru7u75+qs/A/zJweV/6vxWipX3nr/6V/8q/+pf/Sv+m//mv/n8+//qX/0r/tbf+lu/8d8z9ge8g21bKWnmdHJoC6VlUm4MymM8lNJANZy32G7EWoUxYFQjhI1WqrTjrTBfrnSucLo/0JuOUqW7eff2gWWduc7P/OKXG8ZmrNXUBto03rx75OHRsq2JZd5IOfDrX/2cbbtnnEY6b3Cq8eOHj0zTPeN0ot42LtcFrS1dP3B3P9L3DygLMb0y386stytv3x6w1jOOFq00rXXkktm2jW4YePv0xLYG5tvMumys88yHDx+haTSGmuHp6S2DG/j4/oWwZR6f3nCa7gDIKRJDJQfovUcrz7ZsnK8L0/hA50dyWnCm4927b3j9eCasRbrgvNJQpJxItVABZQ19N9IK1NgINVBy4/vvf+T+6ZHT/R3O95xO9+QQGLqOYZiYpiNaGabpwroGltuNjx9e+Ordt7yez3z48IF1CRjTMUwHhunAdDigrSWkSIiRLUR6pZiGA3lZcV3HT37yU77/9XektMmk3CpaKbQGo2XKaQ1CW3DWYbSl5Eq0C6RCUwnjPYd+oDa4LYs0Hkmm2YeHe6yVS9YAb5/uaQ3ytrJtK041emuI80zYi+bl/EpMAW00TSnmZWU6TGzbDe81RlXCcmEcR3TviDFzPp95/v6XHA5H2nRA55Xt8pF13aBpSqls24aOV9brC0o1irXEUrCnCY9Ht0y
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"matrix = np.ones(image.shape, dtype = 'float64')\n",
"\n",
"image_lower = np.uint8(cv.multiply(np.float64(image), matrix, scale = 0.8))\n",
"plt.imshow(image_lower[:, :, ::-1]);"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "65da736b",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAGiCAYAAABZHumlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9SY+1aZ7eh/3u6ZnPFNM751RDd5EN0mbLlglB8I4AV6JWghdceUNwRfSKBDcmYYDfgAS49E5fQJuGLRsEKBg01VKTqh6qKqsy851iOtMz3s89efEEC5BbkAq2paoC3wsIIONkZMTJE3H+4/W/LpFSSnzCJ3zCJ3zCJ/wGQ/66n8AnfMInfMInfML/FD4lq0/4hE/4hE/4jcenZPUJn/AJn/AJv/H4lKw+4RM+4RM+4Tcen5LVJ3zCJ3zCJ/zG41Oy+oRP+IRP+ITfeHxKVp/wCZ/wCZ/wG49PyeoTPuETPuETfuPxKVl9wid8wid8wm88PiWrT/iET/iET/iNx681Wf3Tf/pP+fLLLymKgt///d/nX/yLf/HrfDqf8Amf8Amf8BuKX1uy+s//8/+cv/f3/h7/8B/+Q/7oj/6I//g//o/5m3/zb/Ltt9/+up7SJ3zCJ3zCJ/yGQvy6hGz/w//wP+Sv/bW/xj/7Z//sl4/96Ec/4m/9rb/FP/kn/+TX8ZQ+4RM+4RM+4TcU+tfxQ+d55l//63/N3//7f/+/9/jf+Bt/g3/5L//lX/h6ay3W2l9+HmNkv99zeXmJEOJ/9uf7CZ/wCZ/wCf//R0qJtm15+fIlUv6PD/p+Lcnq4eGBEALPnj377z3+7NkzPn78+Be+/p/8k3/CP/pH/+h/qaf3CZ/wCZ/wCf8L4rvvvuP169f/o1/za0lW/w7/n11RSul/sFP6B//gH/AHf/AHv/z8dD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4f7okxst1taVYrsiyn7zqmaeZ0OjAMHT4ErLWM3UCeF2Qmo2pqyqpEKUUmcsqqZphGpjngkCAkeb1G5hUPH+7ZdxMir3nzvd/hYnfN7Bzz7ABJVVSUzZbVakWRZ8zTBClSFBmSyGq15vceH/jel19wdbnD5JrT+47RTpzbluPpwDh2bLcNKQaC93hv8fOEc5btbo1WW9rzEaUUs3PkWcH6+ZrXrz9js90hpEJpQ1lXZKbgeDxwPp9w88TrVy/JjURwQcITguX2cSTLFXmVU9aGPNfkJmfqLNNgmUfHupFsNxrvO9r2wNQfePXye9i5JbUTPgwM04wf7fJ71bDZrFld7DjuB4KX5PmKu8cT727fUlY5u8sNm4sdXT8wjJEQNDEqfEgEv6xghEjkWnA+PJCbC8q8oL66pm40F9s1zgXObc/79x+YnSArcoQQCGlAGuw8UuQlN9cv+d6Xvwf8xcblfwi/lmSVZRm///u/zx/+4R/yn/6n/+kvH//DP/xD/pP/5D/5lb/Pqr6gKqHrTnh75OqqQBnwaWacA2tVoUtwLiFEoKgyTLUhyzYYndAy0fct0UcIAREdh/0DVeG5eX6BWlV475jnji8+f86pPfB4eMt/9+MWnVuyTBGSQGWJL756xetXhvPZcj51TFPPn/7Jv6HrnrPdbqgrTa4SP//mHbvdMzbba8Kh5+HhhFQ5dbPmOtuwal4hs8gwfmTo7zgfHvjy8wuyvGC7yZ66h5rZOfq+p1ppPnvzmrbtOe6PtKeW8+HIt9+8haSQ0RAsvP7sC5pyw3e/+EDfOl6/+YzL7Q1CwGwnpsFjx8SqKtGypD233N8f2W1eUJcbrD2R65rvff4DPry9ZexmrF1em5QE02yZgiOIhMpz6mpLXAuCTXSxx9nIz77+Bc9fveD6+TPyuubq+jl2GFhXNavVlu3uCi00u+0D7anneDjw9rtbvvrid7i9u+MX332LOI8oXbPbXbK5uGCz26GyjGE
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"image_higher = np.uint8(np.clip(cv.multiply(np.float64(image), matrix, scale = 1.2) , 0, 255))\n",
"plt.imshow(image_higher[:, :, ::-1]);"
]
},
{
"cell_type": "markdown",
"id": "54e22dd0",
"metadata": {},
"source": [
"## Zapisywanie obrazów\n",
"\n",
"Funkcja [`cv.imwrite()`](https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce) zapisuje obraz do pliku. Pierwszy argument to nazwa pliku, drugi argument to obraz, który chcemy zapisać. Np. poniższe polecenie spowodowałoby zapisanie obrazu w formacie PNG w katalogu roboczym:\n",
"\n",
"```python\n",
"cv.imwrite('pawian.png', image)\n",
"```\n",
"\n",
"## Anotowanie\n",
"\n",
"Sprawdźmy w jaki sposób do pustego obrazu dodać kilka obiektów geometrycznych. Użyjemy do tego funkcji [`cv.line()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga7078a9fae8c7e7d13d24dac2520ae4a2), [`cv.circle()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#gaf10604b069374903dbd0f0488cb43670) , [`cv.rectangle()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga07d2f74cadcf8e305e810ce8eed13bc9), [`cv.ellipse()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga28b2267d35786f5f890ca167236cbc69), [`cv.polylines()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#gaa3c25f9fb764b6bef791bf034f6e26f5) i [`cv.putText()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga5126f47f883d730f633d74f07456c576). Funkcje te będą nadpisywały wejściowy obraz.\n",
"\n",
"W powyższych funkcjach pojawiają się wspólne argumenty:\n",
"\n",
"* `img` - obraz, na którym będziemy umieszczać obiekty,\n",
"* `color` - kolor obiektu podany w formacie jako krotka (*tuple*), np. `(255, 0, 0)`; w przypadku obrazów w skali odcieni szarości wystarczy podać wartość skalarną,\n",
"* `thickness` - grubość linii, okręgu, itp.; w przypadku wartości `-1` w przypadku zamkniętych figur jak okrąg, obiekt zostanie wypełniony wewnątrz wskazanym kolorem; domyślna wartość to `1`,\n",
"* `lineType` : rodzaj linii, np. 8-sąsiedztwo, antyaliasing, itp.; domyślnie jest 8-sąsiedztwo, natomiast wartość [`cv.LINE_AA`](https://docs.opencv.org/4.5.3/d0/de1/group__core.html#ggaf076ef45de481ac96e0ab3dc2c29a777a85fdabe5335c9e6656563dfd7c94fb4f) włącza antyaliasing.\n",
"\n",
"Na początku zaimportujemy bibliotekę NumPy i przy pomocy funkcji [`numpy.zeros()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html) utworzymy pusty 3-warstwowy czarny obraz o rozmiarze 512x512."
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "efd40bcf",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec97aca0>"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAcw0lEQVR4nO3db2yV9f3/8VdrTw9dLSet1R6ORVcnc9NCE4tjNI4if7oYKzEumTKzkLg7ONvQ6LJYvNG6LLbxBouGKVEXvzNL1t2AGhKVUSIUCSEjLQ2n1RAWqhTSs0YH5xSEU2jfvxv7ecXDPz0Fqe/2+UjeyXpdn7af84njmQMXJcfMTAAAOJE71RsAACAbhAsA4ArhAgC4QrgAAK4QLgCAK4QLAOAK4QIAuEK4AACuEC4AgCuECwDgypSG69VXX1VFRYVmzZql6upqffjhh1O5HQCAA1MWrn/84x9qamrS888/rwMHDuhnP/uZHnzwQR09enSqtgQAcCBnqn7I7qJFi3Tvv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B1dHQEa44fP265ubm2bdu2b/R9k8mkSWIYhmGcTzKZzLo91/TPuAYHB5VIJFRXVxdcC4fDqq2t1d69eyVJPT09OnfuXMaaWCymysrKYM2F0um0UqlUxgAAZqZrGq5EIiFJKisry7heVlYW3EskEsrPz1dxcfFl11yora1NkUgkmLlz517LbQMAHPlWnirMycnJ+NjMLrp2oSutaW5uVjKZDGZoaOia7RUA4Ms1DVc0GpWki945jYyMBO/CotGoxsbGdOLEicuuuVA4HNbs2bMzBgAwM13TcFVUVCgajaqrqyu4NjY2pu7ubtXU1EiSqqurFQqFMtYMDw+rv78/WAMAwOXkZfsJp06d0r///e/g48HBQfX19amkpES33Xabmpqa9OKLL2revHmaN2+eXnzxRX3ve9/Tr371K0lSJBLRb37zGz377LO66aabVFJSot/97neaP3++VqxYce1eGQBgesr2McSdO3de8pHGNWvWmNn/HolvaWmxaDRq4XDYlixZYvF4PONrnDlzxhoaGqykpMQKCgqsvr7ejh49+o33wOPwDMMw02Mm8zh8jpmZnEmlUopEIlO9DQDAVUomk1k/t8DPKgQAuEK4AACuEC4AgCuECwDgCuECALhCuAAArhAuAIArhAsA4ArhAgC4QrgAAK4QLgCAK4QLAOAK4QIAuEK4AACuEC4AgCuECwDgCuECALhCuAAArhAuAIArhAsA4ArhAgC4QrgAAK4QLgCAK4QLAOAK4QIAuEK4AACuEC4AgCuECwDgCuECALhCuAAArhAuAIArhAsA4ArhAgC4QrgAAK4QLgCAK4QLAOAK4QIAuEK4AACuEC4AgCuECwDgCuECALhCuAAArhAuAIArhAsA4ArhAgC4QrgAAK4QLgCAK4QLAOAK4QIAuEK4AACuEC4AgCuECwDgCuECALhCuAAArhAuAIArhAsA4ArhAgC4QrgAAK4QLgCAK4QLAOAK4QIAuJJVuNra2nTfffepqKhIt9xyix555BEdOnQoY42ZqbW1VbFYTAUFBVq6dKkGBgYy1qTTaTU2Nqq0tFSFhYVatWqVjh07dvWvBgAw7WUVru7ubj399NPat2+furq6dP78edXV1en06dPBmpdeekk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FwhXAAAVwgXAMAVwgUAcIVwAQBcIVwAAFcIFwDAFcIFAHCFcAEAXCFcAABXCBcAwBXCBQBwhXABAFwhXAAAVwgXAMAVwgUAcIVwAQBcIVwAAFcIFwDAlazC9dprr2nBggWaPXu2Zs+ercWLF+v9998P7puZWltbFYvFVFBQoKVLl2pgYCDja6TTaTU2Nqq0tFSFhYVatWqVjh07dm1eDQBg+rMsbN261d599107dOiQHTp0yNavX2+hUMj6+/v
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"\n",
"img = np.zeros((512,512,3), np.uint8)\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "2b23ae8a",
"metadata": {},
"source": [
"W dalszej części operowali na obrazie w formacie RGB.\n",
"\n",
"### Linie\n",
"\n",
"Aby narysować linię, musimy podać początkowe i końcowe współrzędne linii. Przy pomocy [`cv.line()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga7078a9fae8c7e7d13d24dac2520ae4a2) narysujemy na obrazie czerwoną linię od lewego górnego rogu do prawego dolnego rogu o grubości 5 pikseli."
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "eecb08e6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec9d03d0>"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAwhklEQVR4nO3dbWxc5Z3+8csm9sQYZ+pg8MQkZd1tt7s0EAnTZRN1SQiQCvkBBG0hpW1aSlHYJiJqpVVDXyQrrWSLF6xa0RKRpCGUB9MS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/7vqHr1mzxsycJfGbNm2yUChkgUDAbrnlFuvq6or7GRcuXLB169bZ/PnzrayszBoaGuzEiRNTngPBNfUxV+7hdfHS8atyYI4MBqNwx3SCq8jMTD4TiUQUDAazPQ3fmCfn8eBdLp/tkfQ9Sf0unwHAbAuHw2mvW6CrsABEJD2k1MW8l3s9KQCYJoKrQJxV8mLeelHMC8A/CK4CMiLnzutVOQ+Xo6L7vLZKKsnCvAAgHQRXgflEzndabm9SbpTzJuX5Xk8KANJAcBWgc5Lul/s+r0ZJOyRVJv4mAMgRBFeBSlXM2yRppyjmBZCbCK4C1iOnYSNxwYbkNGxQzAsgFxFcBW5Ykxfzlnk9KQBIgeCCPpMTXqmKeak1BpArCC5IknqVvJi3XtLvRTEvgNxAcCFmSNLDchZsuO3z2i5pThbmBQDjEVyI87Gk++S+z6tBzj6vq7yeFACMQ3BhggE5m5QTHxsWy7nz2iapwutJAcAlBBdcRST9WO77vBolPS9WGwLIDoILSZ2VdK/ci3kbJLW
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cv.line(img, (0,0), (511,511), (255,0,0), 5)\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "bb1a0101",
"metadata": {},
"source": [
"### Prostokąty\n",
"\n",
"Aby narysować prostokąt, potrzebujemy lewego górnego rogu i prawego dolnego rogu prostokąta. Tym razem przy pomocy [`cv.rectangle()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga07d2f74cadcf8e305e810ce8eed13bc9) narysujemy zielony prostokąt w prawym górnym rogu obrazu."
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "9d3cc9ad",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ecaa2460>"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCA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RdSFfPWiWJeAPljWlYVBgKBuF+b2ZhjiVKds3btWkUikdg4evRoxuaaT1IV8zbKKead6fWkACDDMhpc4XBYksbcOXV2dsbuwsLhsAYGBtTV1ZX0nETBYFCzZs2KG3AXLeZ1W7DRIOlVUcwLwN8yGlw1NTUKh8NqbW2NHRsYGFBbW5sWLVokSaqtrVVxcXHcOSdOnNCBAwdi52BquiV9V+7FvPVyvvOimBeAX6W91ef06dP63//939ivDx8+rP3796uiokKXX3651qxZo1/+8pe68sordeWVV+qXv/ylLrzwQn3/+9+XJIVCId1///169NFHdfHFF6uiokL/8i//oquvvlo333xz5v5mBS5ZMW/0seEzopgXgE+luwzx7bffdl3iuGLFCjNzlsSvW7fOwuGwBYNBu/766629vT3uZ5w9e9ZWrVplFRUVVlpaavX19XbkyJEJz4Hl8BMfM+UslR9W/DL5c+ePX5IDc2QwsjpYDu/tyMBy+ICZmXymp6dHoVAo29PwjVlyHg/e5vLZTkk/kNTr8hlQEC6Q9Lmk6ELnVyUty9508t5xSdWSeiSFpEgkkva6BboKC0CPpAeUupj3Qq8nBQCTRHAViJNKXsxbJ4p5AfgHwVVAhuTceb0h52FzVHTBxkZJxVmYFwCkg+AqMJ/L+U7L7U3KDXLepFzh9aQAIA0EVwE6Leluue/zapC0RSPfUwNAriG4ClSqYt5GSVtFMS+A3ERwFbBOOQ0biQs2JKdhg2JeALmI4Cpwgxq/mLfU60kBQAoEF/SFnPBKVcxLrTGAXEFwQZLUpeTFvHW
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cv.rectangle(img, (384,0), (510,128), (0,255,0), 3)\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "cdcb4b70",
"metadata": {},
"source": [
"### Okręgi\n",
"\n",
"Aby narysować okrąg, potrzebujemy jego współrzędnych środka i promienia. Przy pomocy [`cv.circle()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#gaf10604b069374903dbd0f0488cb43670) narysujemy okrąg wewnątrz prostokąta narysowanego powyżej."
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "48207862",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec8de790>"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA24ElEQVR4nO3df3yU9Z33+1cCyRAjjGA0QwRd3LrdVZSzxtaVuxX8RY+HBF3bqtRaW7U92MItR/fsKfbcC3vuPU2O5xz3bh+28hAQsVqjlR/SZaXGU4315rjrgqwB++C4K5YfNzEiZBKQ/CKf88eXmWQmM5NMMnPNXDPvZx/fxwNmrky+XJV8+F7X5/u+SszMEBER8YnSXE9AREQkHSpcIiLiKypcIiLiKypcIiLiKypcIiLiKypcIiLiKypcIiLiKypcIiLiKypcIiLiKypcIiLiKzktXD//+c+ZNWsWkyZNora2lt/97ne5nI6IiPhAzgrXCy+8wPLly/nRj37Eu+++y5e//GVuvvlmDhw4kKspiYiID5TkKmT36quv5sorr+SJJ56IvvZnf/Zn3HrrrTQ0NORiSiIi4gMTc/FNe3t72blzJz/84Q9jXl+wYAE7duwYdnxPTw89PT3R3w8MDHDs2DHOPfdcSkpKsj5fERHJLDOjq6uLmpoaSkvTu/iXk8J19OhRTp8+TXV1dczr1dXVtLW1DTu+oaGBv/3bv/VqeiIi4pGDBw8yY8aMtL4mJ4UrIn61ZGYJV1ArVqzgoYceiv4+HA5z4YUXchCYEvlaYDvwXaArWxMWkcJTCnwITD3z+2bgf/FyAtXABGAlUOteOnAh9AUy/62Cx6Hq6JnfPAO8BJwCjmf+eyVSgvtBfR7QCcy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uKK19a414c2bCiYVySPvPllODI917MoDv90NXx04Zi/XIUri04wuM8rvmHjFlwwb8DrSYlIYhf9ASZ35XoWxWHGIQiGx/zlKlxZFgnm3ZbgvTrgVyiYVyQvXHQAzj6R61kUhwsOw1QVrrzWD9zL8H1eJbjLhmvQyktEZLRUuDwSCeZNFA8VWXmd4/GcRET8SIXLQ6mCeetRMK+IyGhoH5fHeki8zwtcw0Yp2uclIpKKVlw50I5beSUL5t2EEjZERJJR4cqRHlIH865BwbwiIomocOVQB8mDeetxwbwqXiIeeuIBKD2d61kUtov/HR7+v8f1ESpcOTZSMO8v0WVDEc9c/GGuZ1D4Aj1Qc2RcH6HmjDygYF6RPFISv2FFMioD51crrjyRKpi3DtewoVZ5kSw7pwNWL8n1LAqYwYu3j/tTVLjyyElgMcODeSP7vNahTcoiWVVqMKUz17MobFOPj/sjVLjyzEngeyQP5n0GxUOJZFc/0JfrSRSoboZfU0qfClceakfBvCK5swV4NteTKFD/EWgb96eocOWpfuA7JA/mfRKtvESywwC1xGdHZlrMVLjy2KfAt0kczFuPW3npYZQi2fAImVgZyFDbgI0Z+SQVrjzXAXyd5MG8G4Aqj+ckUvg+wV0ylMzoxp3PzDyoU4XLB3oZbNiIX3ndAjyFNuSJZN5/QZcMM6UT95MqM1S4fOJjBoN544vXQtwCXAkbIpn0AfCfcj2JAvF1hvdJj50Kl4/0AHczfJ9XKS5hYw1wtteTEilYA8D/A/xbrific6/h/hGQOSpcPhPGBfP+msTBvL9EwbwimfPPwL+Sib1HxakPeAUYXzZhPBUuH/oUl12YLJj3eXTZUCRzvoVrLpD0/QvwWMY/Ne3C9eabb1JfX09NTQ0lJSVs2bIl5n0zY9WqVdTU1FBRUcH8+fPZu3dvzDE9PT0sW7aMqqoqKisrWbRoEYcOHRrXH6TYRIJ54xs2It2Ga1DDhkhm9AB/n+tJ+NBp4P/
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cv.circle(img, (447,63), 63, (0,0,255), -1)\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "60678ca6",
"metadata": {},
"source": [
"### Elipsy\n",
"\n",
"Aby narysować elipsę, musimy przekazać kilka argumentów. Jednym argumentem jest położenie środka `(x, y)`. Następnym argumentem jest długość dwóch osi (długość głównej osi i mniejsza długość osi). Kolejny parametr to kąt obrotu elipsy w kierunku przeciwnym do ruchu wskazówek zegara. Kolejne dwa argumenty oznaczają początek i koniec łuku elipsy mierzonego zgodnie z ruchem wskazówek zegara od głównej osi. tj. podanie wartości `0` i `360` daje pełną elipsę. Aby uzyskać więcej informacji, sprawdź dokumentację [`cv.ellipse()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga28b2267d35786f5f890ca167236cbc69). Poniższy kod rysuje pół elipsy na środku obrazu."
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "4423e4b0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec85ef10>"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA4pklEQVR4nO3dcXzU9Z3v+1cCSYiRjCCaIYIu3druKsqtsbWwraAoPR4SdG2rUmtt1fbaFo4c3btb7N0Fz/Y0qfdee9pjK1dAqtUarYDS2lLDrca6bLcsyBqwl+tWFGSJESETQJIQ8rl/fDOTzGQmySQzv9/8Zt7PPr6PB8z8Mvnws+TD9/f7ft+/IjMzREREAqLY7wJERETSocYlIiKBosYlIiKBosYlIiKBosYlIiKBosYlIiKBosYlIiKBosYlIiKBosYlIiKBosYlIiKB4mvj+vGPf8yMGTOYMG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7ukqFkRifufGbmQZ1qXAHQTf+CjcSZ17XAI2hDnkjm/Q90yTBTOnA/qTJDjSsg3qU/mDexeS3ETcCVsCGSSW8Af+93EXni8wxeJz16alwB0gXcwuB9XsW4hI3VwOleFyWSt3qB/wf4d78LCbgtuH8EZI4aV8BEcMG8vyB5MO/PUDCvSOb8Afg3MrH3qDCdBH4NjC2bMJEaVwC9j8suTBXM+yS6bCiSOV/CLS6Q9P0r8EDGPzXtxvXyyy9TV1dHdXU1RUVFPPvss3HvmxkrV66kurqa8vJy5s2bx+7du+OO6erqYunSpUyZMoWKigoWLVrEO++8M6Y/SKGJBvMmLtiIrjZcjRZsiGRGF/B9v4sIoFPA/5mVT067cR0/fpx
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cv.ellipse(img, (256,256), (100,50), 0, 0, 180, 255, -1)\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "1219997d",
"metadata": {},
"source": [
"### Poligony\n",
"\n",
"Aby narysować wielokąt, najpierw potrzebujemy współrzędnych wierzchołków. Ustawmy te punkty w tablicy o wymiarach `liczba_wierszy x 1 x 2`, gdzie `liczba_wierszy` to liczba wierzchołków i powinna być typu `int32`. Tutaj narysujemy mały wielokąt z czterema wierzchołkami w kolorze jasnoniebieskim."
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "60223ef1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec74a5e0>"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA7dklEQVR4nO3dfXxU5b33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vG/acsNHzsmH2LYQTyQZfRQthku2zwMVJeSc1rn40YJ/XFWudVwWwBt26Fcksp6C/1anyCZIxP1uNawA+xjav6NmGOdhFyiuxV3BFJBNcAVzldhEZ6jsk4x8FalwDdBT7yJP19J6wUYl9gLeWKIqIpJ4aVwIOEn/CRmi2YanTRYlI8rTlwp8nuV1FZvv9/xjyW/iMMdG3btJeU1MTfr97F+dGYSdm9HyScsiLwLUomFfEM4Zh/1VaAnxUAqcdhM5hLheVwf7lHXjnPJu154dgMEhxcXFCb6EzrkE4hF2kHG/Cxmrs7V0REUk+Na5BCtJ/MO+pDtckIkP0wmwwelBkSn00En43tGnxalxD0IJd5xUrmHc2sAoF84p4ys++DkY/FlPqwwCsu2pIb6E/oSFqwAbzRk/YAJuwsRoF84qIJJMaVxK0YR9GGR3MG1rntQIodLooEZEMpcaVJI3AbcRe51UBPIOCeUVEkkGNK4kO0/c6r6fRZUMRkaFSRmySdWAnbIC9TBianxQK5vVhn6na4XxpIiIZQWdcKdBXMO9MFMwrIjIUalwpcgzbvNZHbe85YUPBvCJp5I3Pw4HRbleRHf54Ebw/btDfrsaVQkfpXucVPWFjNjaYN9/pokQktjM/gKJmt6v
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pts = np.array([[10,5], [20,30], [70,20], [50,10]], np.int32)\n",
"pts = pts.reshape((-1, 1, 2))\n",
"cv.polylines(img, [pts], True, (0,255,255))\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "cdba71d3",
"metadata": {},
"source": [
"Wielokąt może wydawać się przerywany, ale jeśli powiększylibyśmy wynikowy obraz, to byśmy zobaczyli, że jest on zamknięty.\n",
"\n",
"Jeśli trzecim argumentem [`cv.polylines()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#gaa3c25f9fb764b6bef791bf034f6e26f5) jest `False`, otrzymamy niedomknięty poligon.\n",
"\n",
"Funkcja `cv.polylines()` może być używana do rysowania wielu linii. Wystarczy utworzyć listę wszystkich linii, które chcemy narysować i przekazać je do funkcji. Wszystkie linie zostaną narysowane osobno. Jest to znacznie szybszy sposób na narysowanie grupy linii niż wywołanie osobno [`cv.line()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga7078a9fae8c7e7d13d24dac2520ae4a2) dla każdej linii.\n",
"\n",
"### Tekst\n",
"\n",
"Aby umieścić tekst na obrazie, musimy określić następujące rzeczy:\n",
"\n",
"* dane tekstowe, które chcemy napisać,\n",
"* współrzędne miejsca, w którym chcemy umieścić tekst (np. lewy dolny róg, w którym zacznie się tekst),\n",
"* typ czcionki (sprawdź dokumentację [`cv.putText()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga5126f47f883d730f633d74f07456c576) dla obsługiwanych czcionek),\n",
"* rozmiar czcionki,\n",
"* pozostałe rzeczy takie jak kolor, grubość, typ linii, itp.; dla uzyskania lepszego wynikowego wyglądu zaleca się `lineType = `[`cv.LINE_AA`](https://docs.opencv.org/4.5.3/d0/de1/group__core.html#ggaf076ef45de481ac96e0ab3dc2c29a777a85fdabe5335c9e6656563dfd7c94fb4f).\n",
"\n",
"Na naszym obrazie umieścimy tekst w kolorze białym."
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "2de2bcf6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec84c850>"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAABnkklEQVR4nO3dd3xUZfb48c9MegIJCQkp9GZBEBWlKyCIqwQUFLCXtaGri7qu9fdddHUX1nX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wo0MRVT4UYS56soPqAjbEYC3jrFEWllPI8TVwNcJLaB2yUjzZM9HZQSin3KQuBby71dRTN25dDmrwLk4hUvXXj9/Lz84mJ8d3FuXiMgRkVV1IutxK4ES3Mq1TACML4VBoL5MRCwklwBvk4qGbs/B/ghwuMWnsxYLFYiI6ObtAutMfVCNkYk5RrG7CxBOP2rlJKKffTxNVIFs5emLetl2NSSjXR8utAdKFIj8qJg8+bNixeE1cTlGLM86qpMO91wNtoYV6lAsp/HwLRt0WPOpEEy65v0i70J9REWRiFeasO2ACjwsYStDCvUkq5kyYuNyjDWIyyamHe8nles4EobwellFLNlCYuN8kD7qHmeV6pwEK0MK9SSrmDJi43OkXd87zeRS8bKqVUU2mNWDezYwzYAOMyYfn4pPLCvCaMNVXt3g9NKaWaBe1xeUBdhXnHoIV5lVKqKTRxeUgRRvJaUeXxigM2tDCvUn5k0+WQmezrKFqGrwfAoU6N/nZNXB5UyJl5XlUHbFyHUZg3zNtBKaVq1vkwtC7wdRQ
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cv.putText(img, 'OpenCV', (10,500), cv.FONT_HERSHEY_SIMPLEX, 4, (255,255,255), 2, cv.LINE_AA)\n",
"\n",
"plt.imshow(img)"
]
},
{
"cell_type": "markdown",
"id": "326c28ac",
"metadata": {},
"source": [
"Czasami potrzebujemy jednak dokładnych informacji o wynikowym tekście, tak aby np. odpowiednio go umiejscowić lub umieścić pod nim kontrastowe tło. Do uzyskania tych informacji pomocne są funkcje [`cv.getTextSize()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga3d2abfcb995fd2db908c8288199dba82) i [`cv.getFontScaleFromHeight()`](https://docs.opencv.org/4.5.3/d6/d6e/group__imgproc__draw.html#ga442ff925c1a957794a1309e0ed3ba2c3)."
]
},
{
"cell_type": "markdown",
"id": "eec58cd3",
"metadata": {},
"source": [
"## Wyświetlanie obrazów poza Jupyterem\n",
"\n",
"### HighGUI\n",
"\n",
"W OpenCV obraz standardowo wyświetla się przy pomocy modułu HighGUI. Przy użyciu funkcji [`cv.imshow()`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563) możemy wyświetlić obraz w oknie. Okno automatycznie dopasowuje się do rozmiaru obrazu.\n",
"\n",
"Pierwszy argument to nazwa okna. Drugi argument to nasz obraz. Możemy utworzyć dowolną liczbę okien, ale z różnymi nazwami okien.\n",
"\n",
"```python\n",
"cv.imshow('image', image)\n",
"cv.waitKey(0)\n",
"```\n",
"\n",
"Pod Windowsem wyświetli nam się wskazany przez nas obraz, natomiast pod Linuxem mechanizm HighGUI przy wyświetlaniu obrazu udostępnia trochę więcej opcji i informacji o wyświetlanym obrazie.\n",
"\n",
"![Obraz pawiana wyświetlony przy pomocy HighGUI](img/highgui-baboon.png)\n",
"\n",
"Zwróćmy uwagę, że obraz pojawia się dopiero po poleceniu `cv.waitKey(0)` oraz będzie oczekiwał na wciśnięcie klawisza.\n",
"\n",
"[`cv.waitKey()`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7) jest funkcją związaną z klawiaturą. Jej argumentem jest czas w milisekundach. Funkcja czeka przez określony czas na każde zdarzenie klawiatury. Jeśli w tym czasie zostanie naciśnięty dowolny klawisz, program przejdzie do dalszych operacji. Jeśli jako argument zostanie przekazane 0, to funkcja czeka bez końca na uderzenie klawisza klawiatury. Można również ustawić wykrywanie konkretnych klawiszy, takich jak naciśnięcie klawisza `<A>`, itp. Poza przetwarzaniem zdarzeń klawiatury, ta funkcja przetwarza również wiele innych zdarzeń GUI, więc **musisz** użyć jej przy wyświetleniu obrazu.\n",
"\n",
"Klikając na obraz i wciskając `<Enter>`, konsola zwróci informację liczbową o wciśniętym klawiszu, a ponadto obsługa programu wróci z powrotem do konsoli. Wydając poniższe polecenie usuniemy wszystkie okna:\n",
"\n",
"```python\n",
"cv.destroyAllWindows()\n",
"```\n",
"\n",
"[`cv.destroyAllWindows()`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ga6b7fc1c1a8960438156912027b38f481) usuwa wszystkie utworzone przez nas okna, a jeśli chcemy usunąć konkretne okno, należy użyć funkcji [`cv.destroyWindow()`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ga851ccdd6961022d1d5b4c4f255dbab34), w której jako argument podajemy dokładną nazwę okna.\n",
"\n",
"Istnieje specjalny przypadek, w którym możemy utworzyć okno i później załadować do niego obraz. W takim przypadku określamy czy rozmiar okna jest zmienny, czy nie. Robi się to za pomocą funkcji [`cv.namedWindow()`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ga5afdf8410934fd099df85c75b2e0888b). Domyślna flaga to [`cv.WINDOW_AUTOSIZE`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ggabf7d2c5625bc59ac130287f925557ac3acf621ace7a54954cbac01df27e47228f), ale jeśli określimy flagę jako [`cv.WINDOW_NORMAL`](https://docs.opencv.org/4.5.3/d7/dfc/group__highgui.html#ggabf7d2c5625bc59ac130287f925557ac3a29e45c5af696f73ce5e153601e5ca0f1), to możemy zmienić rozmiar okna. Będzie to pomocne, gdy obraz jest zbyt duży:\n",
"\n",
"```python\n",
"cv.namedWindow('image', cv.WINDOW_NORMAL)\n",
"cv.imshow('image', image)\n",
"cv.waitKey(0)\n",
"cv.destroyAllWindows()\n",
"```\n",
"\n",
"Interfejs HighGUI czasami pomaga w debugowaniu, ale trzeba mieć też świadomość, że nie jest on specjalnie rozbudowany i zasadniczo nie służy do budowania zaawansowanych interfejsów graficznych. HighGUI obsługuje sygnały idące nie tylko z klawiatury, ale również myszy, a ponadto pozawala na umieszczenie np. sliderów. Krótkie przykłady znajdują się w samouczkach opisujących [`cv.setMouseCallback()`](https://docs.opencv.org/4.5.3/db/d5b/tutorial_py_mouse_handling.html) oraz [`cv.getTrackbarPos()` i `cv.createTrackbar()`](https://docs.opencv.org/4.5.3/d9/dc8/tutorial_py_trackbar.html).\n",
"\n",
"### Matplotlib\n",
"\n",
"Po przekonwertowaniu obrazu do formatu RGB wyświetlamy go przy pomocy `pyplot`. Używamy przy tym funkcji [`matplotlib.pyplot.imshow()`](https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow) oraz [`matplotlib.pyplot.show()`](https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show):\n",
"\n",
"```python\n",
"plt.imshow(image2)\n",
"plt.show()\n",
"```\n",
"\n",
"Funkcja [`matplotlib.pyplot.show()`](https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show) posiada opcjonalny argument `block` (domyślna wartość `True`), która kontroluje czy funkcja jest blokująca:\n",
"\n",
"```python\n",
"plt.imshow(image2)\n",
"plt.show(False)\n",
"```\n",
"\n",
"lub krócej:\n",
"\n",
"```python\n",
"plt.imshow(image2)\n",
"plt.show(0)\n",
"```\n",
"\n",
"**Uwaga**: jeżeli w skrypcie ustawimy argument `block` na `False`, to po uruchomieniu skryptu najprawdopodobniej nie zobaczymy wynikowego obrazu/diagramu, ponieważ skrypt zacznie wykonywać dalsze polecenia i np. zakończy działanie programu. Ustawienie argumentu `block` na `False` najlepiej sprawdza się podczas pracy/eksperymentowania w konsoli interpretera Pythona.\n",
"\n",
"## Moduły\n",
"\n",
"[Lista modułów OpenCV](https://docs.opencv.org/4.5.3/) jest dość długa i zawiera pakiety algorytmów m.in. dla przetwarzania obrazów, uczenia maszynowego, głębokich sieci neuronowych, fotografii obliczeniowej, dedykowane rozwiązania dla CUDA, przepływ optyczny, operacje dla obrazów w logice rozmytej, przetwarzania RGB-D i wiele, wiele innych. Z poziomu Pythona dostęp do poszczególnych algorytmów odbywa się bezpośrednio przez moduł `cv2` (u nas alias `cv`). Część klas i funkcji ma przedrostek oznaczający moduł, np. `cv.bgsegm_BackgroundSubtractorCNT(...)` oznacza klasę [BackgroundSubtractorCNT](https://docs.opencv.org/4.5.3/de/dca/classcv_1_1bgsegm_1_1BackgroundSubtractorCNT.html) z modułu [bgsegm](https://docs.opencv.org/4.5.3/df/d5d/namespacecv_1_1bgsegm.html) zawierającym udoskonalone metody segmentacji pomiędzy tłem a pierwszym planem.\n",
"\n",
"## Ćwiczenie 1\n",
"\n",
"Wczytaj plik [`img/soyjaks.jpg`](https://knowyourmeme.com/memes/two-soyjaks-pointing) i spróbuj odtworzyć poniższy obrazek."
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "ff692a8e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0ec8bb670>"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAGiCAYAAADnSLH4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9d7xt11nfC3/HGLOtuuvpTdJROeqyZVtyt3EBAzY2EAwEAiQXAiYEBy5gSm4gIcANNySEFlJuIHQwfnEvso2rZMtW7/30c3Zvq805R3n/GGOutXY5ksj7ua9fvZxHn6O991qzjDHmmE/5PU045xwX6SJdpIt0kf7ek/xaD+AiXaSLdJEu0v9v0EWBcJEu0kW6SBcJuCgQLtJFukgX6SIFuigQLtJFukgX6SIBFwXCRbpIF+kiXaRAFwXCRbpIF+kiXSTgokC4SBfpIl2kixTookC4SBfpIl2kiwRcFAgX6SJdpIt0kQJdFAgX6SJdpIt0kYCvsUD43d/9XS699FKyLOPmm2/m85///NdyOBfpIl2ki/T3mr5mAuEv/uIvePe7383P//zPc8899/DqV7+at7zlLZw8efJrNaSLdJEu0kX6e03ia1Xc7pZbbuHFL34xv/d7vzf87Oqrr+btb387v/qrv/q1GNJFukgX6SL9vaboa3HToii46667eM973rPp8ze/+c3cfvvt247P85w8z4d/W2tZXl5mZm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qoKEbFKSqOiVKJFAIlQSm8Fu0cOjBO/3J7xiqDOWqFxdgCXebkecH6xgZSRkxOzJJlGfsOHGLfgcP0nniENNIUxmv31ia
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# miejsce na eksperymenty\n",
"img_soy = cv.imread(\"img/soyjaks.jpg\", cv.IMREAD_COLOR)\n",
"img_soy = cv.cvtColor(img_soy, cv.COLOR_BGR2RGB)\n",
"img_soy = img_soy[0:500, 50:500]\n",
"cv.putText(img_soy, 'OMG not chikenz!', (10,80), cv.FONT_HERSHEY_PLAIN , 3, (255,0,0), 5, cv.FILLED)\n",
"cv.circle(img_soy, (275,225), 50, (255,0,255), 10)\n",
"plt.imshow(img_soy)"
]
},
{
"cell_type": "markdown",
"id": "279f1a5d",
"metadata": {},
"source": [
"![Two Soyjaks Pointing](img/soyjaks-final.png)"
]
},
{
"cell_type": "markdown",
"id": "288aa117",
"metadata": {},
"source": [
"## Ćwiczenie 2\n",
"\n",
"Załaduj obrazy `img/pipe.png` oraz `img/man-without-pipe.png` i wykonaj operacje tak, aby uzyskać poniższy obraz."
]
},
{
"cell_type": "code",
"execution_count": 93,
"id": "2cb83db1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 76 56 64 255]\n"
]
},
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fe0e5f52700>"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAacAAAGiCAYAAABDIgkrAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9TaxtWXbXC/7m1/rYe59z7r0RmZGZGPMAlUsILJUwKmMkBB0suYWh81q0oYncwnLHRha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z3W7UOoViH/N6jNv1WvexO8MVYb43f2VFfe+PH46D9yML6/3SL/0Sf+/v/T3+yl/5K/zcz/0c/+pf/Sv+4A/+gH/wD/7BH29DitUZ5Ta5gMz0NjGlVFejdt+rn1PvTNa6uintlszrKkmjMKqsEN45S9c5+opcckqkmEjBU1JEkTFGwmPL4skpk5wjpLiispyLPHxa0XcDWsl2Yoh19Z2JfuE5eJRSBO8h5YqOIjFEUszEVPDPV6Z5kpV4EEQmzsoDimUJXC7fI2cx+ClnjLFkpXh+PjPNC6mGzXrryCVx8YHFBwpwOIw4ozkdej75+AUxBIbxRNf1vH565vk8scwLRsP93YFpniW0CMSUmeZALpFSCtpYrHV0rkObTApBkGHfkVIiUVDOYY0mq4LSjlSNrnMdwU8YLds1RpNSIiyzOBYEdWmliCmjizjswziglMYvnpQzKWdKSmiliSkxs9B1Awrwy1WMOxCDR2tL8J4YI8ZajFLioDpH13UsfmGOgVLAaA1ZnENOmZQS3keW2WONPHbeB0KMpJQkRGs0fe8Yh55xGHCdpSSPdj2HhxcYa4i
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# miejsce na eksperymenty\n",
"img_pipe = cv.cvtColor(cv.imread(\"img/pipe.png\", cv.IMREAD_UNCHANGED), cv.COLOR_BGRA2RGBA)\n",
"img_man_no_pipe = cv.cvtColor(cv.imread(\"img/man-without-pipe.png\", cv.IMREAD_UNCHANGED), cv.COLOR_BGRA2RGBA)\n",
"img_man_pipe = img_man_no_pipe\n",
"img_pipe = cv.flip(cv.resize(img_pipe, None, fx=0.55, fy=0.55, interpolation=cv.INTER_AREA), 1)\n",
"rows,cols,channels = img_pipe.shape\n",
"print(img_pipe[50,50])\n",
"for r in range(rows):\n",
" for c in range(cols):\n",
" if img_pipe[r,c,3] > 150:\n",
" img_man_pipe[278+r, 65+c] = img_pipe[r,c]\n",
"#img_man_pipe[275:275+rows,70:70+cols] = img_pipe\n",
"plt.imshow(img_man_pipe)"
]
},
{
"cell_type": "markdown",
"id": "7baba75b",
"metadata": {},
"source": [
"![Człowiek z fajką](img/man-with-pipe.png)"
]
},
{
"cell_type": "markdown",
"id": "f0b793fc",
"metadata": {},
"source": [
"## Co dalej?\n",
"\n",
"Przygotuj środowisko pracy instalując wygodne dla Ciebie IDE, np. [PyCharm](https://www.jetbrains.com/pycharm/) (są darmowe studenckie licencje), [Visual Studio](https://visualstudio.microsoft.com) z dodatkiem [Python Tools](https://microsoft.github.io/PTVS/) lub [Visual Studio Code](https://code.visualstudio.com/). Sprawdź czy możesz zaimportować OpenCV, ew. stwórz wirtualne środowisko i doinstaluj niezbędne paczki."
]
},
{
"cell_type": "markdown",
"id": "4a713f31",
"metadata": {},
"source": [
"----\n",
"\n",
"Źródło:\n",
"\n",
"* OpenCV, [Getting Started with Images](https://docs.opencv.org/4.5.3/dc/d2e/tutorial_py_image_display.html).\n",
"* OpenCV, [Drawing Functions in OpenCV](https://docs.opencv.org/4.5.3/dc/da5/tutorial_py_drawing_functions.html).\n",
"* P. Pandey, [Face Detection with Python using OpenCV](https://www.datacamp.com/community/tutorials/face-detection-python-opencv)."
]
}
],
"metadata": {
"author": "Andrzej Wójtowicz",
"email": "andre@amu.edu.pl",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"lang": "pl",
"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.9.2"
},
"subtitle": "01. Wprowadzenie do widzenia komputerowego [laboratoria]",
"title": "Widzenie komputerowe",
"year": "2021"
},
"nbformat": 4,
"nbformat_minor": 5
}