{ "cells": [ { "cell_type": "code", "execution_count": 5, "id": "96bd3881-21dd-4a8f-9843-24d70a350ed3", "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'img_array' is not defined", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[5], line 4\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mcv2\u001b[39;00m\n\u001b[0;32m 3\u001b[0m ing_array \u001b[38;5;241m=\u001b[39m[[[\u001b[38;5;241m0\u001b[39m,\u001b[38;5;241m225\u001b[39m,\u001b[38;5;241m0\u001b[39m,\u001b[38;5;241m128\u001b[39m]\u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m255\u001b[39m)]\u001b[38;5;28;01mfor\u001b[39;00m j \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m255\u001b[39m)]\n\u001b[1;32m----> 4\u001b[0m ing_numpy \u001b[38;5;241m=\u001b[39m numpy\u001b[38;5;241m.\u001b[39marray(\u001b[43mimg_array\u001b[49m)\n\u001b[0;32m 5\u001b[0m cv2\u001b[38;5;241m.\u001b[39mimwrite(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m1.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m,img_numpy)\n", "\u001b[1;31mNameError\u001b[0m: name 'img_array' is not defined" ] } ], "source": [ "import numpy\n", "import cv2\n", "img_array =[[[0,225,0,128]for i in range(255)]for j in range(255)]\n", "ing_numpy = numpy.array(img_array)\n", "cv2.imwrite(\"1.jpg\",img_numpy)" ] }, { "cell_type": "code", "execution_count": null, "id": "a05da14c-1d85-4d64-9c30-aed5c5b958e2", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "acb124d0-018d-4c77-a5a4-0e4eecbf2964", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 5 }