plot image

This commit is contained in:
2026-01-27 11:28:15 +00:00
parent a58c86ddee
commit ef0abd57d4
2 changed files with 86 additions and 5 deletions

76
extract_data.ipynb Normal file
View File

@@ -0,0 +1,76 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"id": "13389e33",
"metadata": {},
"outputs": [],
"source": [
"import extract_data as ed"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "e5de5ac0",
"metadata": {},
"outputs": [],
"source": [
"imgs = ed.get_images(ed.PHOTOS_PATH)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "575fd8c9",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'extract_data' has no attribute 'plot_image'",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mAttributeError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[9]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m img = ed.convert_to_opencv_image(imgs[\u001b[32m0\u001b[39m])\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[43med\u001b[49m\u001b[43m.\u001b[49m\u001b[43mplot_image\u001b[49m(img)\n",
"\u001b[31mAttributeError\u001b[39m: module 'extract_data' has no attribute 'plot_image'"
]
}
],
"source": [
"img = ed.convert_to_opencv_image(imgs[0])\n",
"ed.plot_image(img)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b8b7bebc",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -1,6 +1,8 @@
import os import os
from datetime import datetime from datetime import datetime
import matplotlib.pyplot as plt
import cv2 as cv import cv2 as cv
import numpy as np import numpy as np
import pandas as pd import pandas as pd
@@ -9,7 +11,6 @@ from PIL import Image
PHOTOS_PATH = "./photos/" PHOTOS_PATH = "./photos/"
# Get a list of images given a directory path # Get a list of images given a directory path
def get_images(url: str): def get_images(url: str):
images = [] images = []
@@ -126,6 +127,13 @@ def preview_image(img: np.ndarray):
cv.waitKey(0) cv.waitKey(0)
cv.destroyAllWindows() cv.destroyAllWindows()
def plot_image(img, figsize=(6,6)):
fig, ax = plt.subplots(figsize=figsize)
ax.imshow(img)
ax.axis("off")
return fig
def __main__(): def __main__():
imgs = get_images(PHOTOS_PATH) imgs = get_images(PHOTOS_PATH)
@@ -158,6 +166,3 @@ def __main__():
print("fail_len: ", len(fail)) print("fail_len: ", len(fail))
return None return None
__main__()