Spaces:
Runtime error
Runtime error
Sagar Bharadwaj commited on
Commit ·
804cbcd
1
Parent(s): 54cb6c5
Updated notebook example
Browse files2 unmodified lines3456789101112131415166 unmodified lines232425262728293031323334353637383940414243444546472 unmodified lines{"cell_type": "code","execution_count": null,"id": "af221ec3-755c-42d5-8bb4-739644c482b6","metadata": {},"outputs": [],"source": ["import cv2\n","\n","from colorbynumber.utils import show_image\n","from colorbynumber.simplify_image import simplify_image"]},{6 unmodified lines"# Image from: https://www.pexels.com/photo/scarlet-macaw-1618424/\n","# Photographer: Tim Mossholder\n","\n","image = cv2.imread(\"ExampleImages/Macaw.jpeg\")\n","image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n","show_image(image)"]},{"cell_type": "code","execution_count": null,"id": "7368c3bd-a7a6-467b-be90-cf628d5b3b81","metadata": {},"outputs": [],"source": ["color_list = [\n"," (255, 0, 0), # Red\n"," (0, 255, 0), # Green\n"," (0, 0, 255), # Blue\n","]\n","simplified_image = simplify_image(image, color_list)\n","show_image(simplified_image)"]}],2 unmodified lines345678910111213146 unmodified lines2122232425262728293031323334353637383940414243444546474849505152535455565758596061626364652 unmodified lines{"cell_type": "code","execution_count": null,"id": "44153707-a329-46d4-8eda-d0ffe1304999","metadata": {},"outputs": [],"source": ["from colorbynumber.main import ColorByNumber\n","from colorbynumber import utils"]},{6 unmodified lines"# Image from: https://www.pexels.com/photo/scarlet-macaw-1618424/\n","# Photographer: Tim Mossholder\n","\n","image_path = \"ExampleImages/Macaw.jpeg\"\n","color_list = [\n"," (255, 5, 0), # Red\n"," (2, 94, 3), # Dark Green\n"," (0, 0, 255), # Blue\n"," (216, 235, 52), # Yellow\n"," (0,0,0), # Black\n"," (255, 255, 255), # White\n","]\n","\n","config = {\n"," \"denoise\": True,\n"," \"denoise_h\": 100,\n"," \"border_padding\": 2,\n"," \"area_perc_threshold\": 0.5,\n"," \"arc_length_area_ratio_threshold\": 1,\n"," \"border_color\": (0, 0, 0),\n"," \"font_size\": 0.5,\n"," \"font_color\": (0, 0, 0),\n"," \"font_thickness\": 1,\n","}\n","\n","colorbynumber_obj = ColorByNumber(\n"," image_path = image_path, \n"," color_list = color_list,\n"," config = config,\n",")\n","numbered_islands = colorbynumber_obj.create_color_by_number()\n","utils.show_image(numbered_islands, cmap = 'grey')"]},{"cell_type": "code","execution_count": null,"id": "b278a3ff-907b-43db-b7c8-c84803a4c1a7","metadata": {},"outputs": [],"source": ["utils.save_image(numbered_islands, \"Macaw_with_numbers_05_perc.png\")"]}],
ColorByNumber.ipynb+34-16