{"id":1328,"date":"2019-07-13T09:15:18","date_gmt":"2019-07-13T14:15:18","guid":{"rendered":"http:\/\/jimlund.org\/blog\/?page_id=1328"},"modified":"2020-09-12T17:23:02","modified_gmt":"2020-09-12T22:23:02","slug":"image-to-tiles","status":"publish","type":"page","link":"http:\/\/jimlund.org\/blog\/?page_id=1328","title":{"rendered":"Image to tiles"},"content":{"rendered":"\n<p><strong>Gimp process<\/strong><br>Gaussian blur 1-3 px x5<br>Mode -&gt; Indexed using palette<br>Mode -&gt; RGB<br>Save detailed palette image<br><br><em>Edges<\/em><br>Enhance -&gt; Despeckle<br>Edge detect -&gt; Sobel 1.0<br>Threshold<br>Save edge image<br><br><em>Blocks<\/em><br>Move to larger blocks \/ pixelate<br>Enhance -&gt; Despeckle<br>Save block imag<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Inkscape for edge finding<\/strong><br>Extensions -&gt; Modify path -&gt; Flatten beziers 2.0<br>Gives one path with all segments<br>Path -&gt; Break Apart.  Check, clean up.<br>Save as SVG.<\/p>\n\n\n\n<p><br>Info on edge detection, <a href=\"http:\/\/homepages.inf.ed.ac.uk\/rbf\/CVonline\/LOCAL_COPIES\/OWENS\/\">link<\/a>, <a href=\"http:\/\/homepages.inf.ed.ac.uk\/rbf\/CVonline\/LOCAL_COPIES\/OWENS\/LECT7\/node2.html#SECTION00020000000000000000\">link<\/a>, <br><strong>Making an Inkscape Extension<\/strong><br>Inkscape docs: <a href=\"https:\/\/inkscape.org\/develop\/extensions\/\">main<\/a>, <a href=\"https:\/\/inkscape.org\/develop\/about-svg\/\">SVG<\/a>, <a href=\"https:\/\/www.w3.org\/Graphics\/SVG\/IG\/resources\/svgprimer.html\">SVG<\/a>, <a href=\"https:\/\/pillow.readthedocs.io\/en\/3.0.x\/handbook\/tutorial.html\">Python Pillow<\/a>, <br>Start from copy of Jitternodes extension.<br><br><strong>Blocks<\/strong><br>Save image to blocks as single pixels<br>Iterate over block pixels<br>  -Add connected pixels to queue.<br>  -Result is blocks with (pixel set, # of pixels, longest edge).<br><br><br><\/p>\n\n\n\n<p>Steps to use Inkscape extensions to tile image:<br>Have use setup up guidelines using different extensions.  Can use this code to have an extension write to a tile config file:<br>&#8212;from gimp_xcf.py&#8212;<br>svg_file = self.args[-1]<br>ttmp_orig = self.document.getroot()<br>docname = ttmp_orig.get(inkex.addNS(&#8216;docname&#8217;,u&#8217;sodipodi&#8217;))<br>if docname is None: docname = self.args[-1]<br>&#8212;&#8212;<br>Commands:<br> -For a border, tile on one\/both sides, tile in from edges or horrizontal\/vertical, fanning our from a seed<br> -Set background color(s)<br> -Tile background color horizontal \/ vertical, fanning our from seeds (set seed locations).  Could put &#8216;control cues&#8217; on a second layer.<br><br>Also, can tile in pieces, first a border, then another, or highlights, etc.  Return tiles on a tile layer.  This way the user can delete particularly bad ones, or backup and try a different approach.<br><br>For adding a new layer with a path, look to spirograph.py.<\/p>\n\n\n\n<p><strong>Image palette<\/strong><br>Using ImageMagick, make a montage image of color swatches. <br>Open in Gimp make image indexed with the correct number of colors.<br>Duplicate palette, rename, save.<br>Palette will be in ~\/.gimp-2.8\/palettes\/&lt;name>.gpl<br><br>Open mosaic image, index to palette.  Save as a png.<br>Extract palette RBG colors from an image:<br>  convert &lt;mosaic>.png -unique-colors -depth 16 txt:- > palette.txt<br><br>Resizing an image.  Convert with &#8216;-sample&#8217; to maintain color palette.  Ordinary resizing adds new colors.<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><strong>Links<\/strong><br><a href=\"https:\/\/visihow.com\/Use_the_Pixelate_Effect_on_Images_in_GIMP\">Use the Pixelate Effect on Images in GIMP<\/a><br><a href=\"https:\/\/graphicdesign.stackexchange.com\/questions\/38131\/how-to-smooth-a-scanned-image-using-gimp\">How to smooth a scanned image using Gimp<\/a><br><a href=\"https:\/\/imgur.com\/gallery\/xL0Ba\">Convert a simple image to a vector graphic using GIMP and Inkscape<\/a><br>&#8220;XDoG: An eXtended difference-of-Gaussians compendium including advanced image stylization&#8221;, <a href=\".\/pics\/winnemoeller-cag2012.pdf\">pdf<\/a><br><a href=\"https:\/\/gis.stackexchange.com\/questions\/340284\/converting-raster-pixels-to-polygons-with-gdal-python\">Converting raster pixels to polygons with GDAL python<\/a><br>ArcGIS <a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/tool-reference\/conversion\/raster-to-polygon.htm\">Raster to Polygon (Conversion)<\/a><br><a href=\"https:\/\/en.wikipedia.org\/wiki\/Straight_skeleton\">Straight skeleton<\/a><br><a href=\"https:\/\/gis.stackexchange.com\/questions\/136143\/how-to-compute-straight-skeletons-using-python\">How to compute Straight Skeletons using Python?<\/a><br><a href=\"https:\/\/www.pyimagesearch.com\/2014\/07\/28\/a-slic-superpixel-tutorial-using-python\/\">Segmentation: A Simple Linear Iterative Clustering (SLIC) Superpixel Tutorial using Python<\/a><br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/jimlund.org\/blog\/wp-content\/uploads\/2020\/09\/SLIC_pixelate.png\" alt=\"\" class=\"wp-image-1679\"\/><\/figure>\n\n\n\n<p>OpenCV <a href=\"https:\/\/opencv-python-tutroals.readthedocs.io\/en\/latest\/py_tutorials\/py_imgproc\/py_morphological_ops\/py_morphological_ops.html\">Morphological Transformations<\/a><br><a href=\"https:\/\/www.pyimagesearch.com\/2014\/10\/20\/finding-shapes-images-using-python-opencv\/\">Finding Shapes in Images using Python and OpenCV<\/a><br><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2019\/04\/introduction-image-segmentation-techniques-python\/\">Computer Vision Tutorial: A Step-by-Step Introduction to Image Segmentation Techniques (Part 1)<\/a><br><a href=\"https:\/\/stackoverflow.com\/questions\/57282935\/how-to-detect-area-of-pixels-with-the-same-color-using-opencv\">How to detect area of pixels with the same color using OpenCV<\/a><br>scikit-image: <a href=\"https:\/\/scikit-image.org\/docs\/dev\/auto_examples\/segmentation\/plot_segmentations.html\">Comparison of segmentation and superpixel algorithms<\/a><br>scikit-image: <a href=\"https:\/\/scikit-image.org\/docs\/dev\/api\/skimage.segmentation.html\">Module: segmentation<\/a><br><br>Polygon splitting<br><a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/help\/editing\/divide-a-polygon-by-a-value.htm\">Divide a polygon by a value<\/a><br><\/p>\n\n\n\n<p><strong><br>Inkscape extentions<\/strong><br><a href=\"https:\/\/wiki.inkscape.org\/wiki\/index.php\/Script_extensions\">Script extensions<\/a><br><a href=\"https:\/\/inkscape.org\/gallery\/=extension\/\">Inkscape extention gallery<\/a><br><a href=\"https:\/\/inkscape.org\/develop\/extensions\/\">How to Write Extensions<\/a><br><a href=\"https:\/\/inkscape.gitlab.io\/extensions\/documentation\/inkex.html#module-inkex.styles\">inkex package<\/a><br><a href=\"http:\/\/inkscape_extensions\">Inkscape extensions chat<\/a><br><br><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><br><\/p>\n\n\n\n<p>Links:<br><a href=\"http:\/\/ https:\/\/blog.mozaico.com\/transforming-images-to-mosaic-patterns\/\">5 Methods of Transforming Images to Mosaic Patterns<\/a><br>  -Not directly applicable, more arty.<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gimp processGaussian blur 1-3 px x5Mode -&gt; Indexed using paletteMode -&gt; RGBSave detailed palette image EdgesEnhance -&gt; DespeckleEdge detect -&gt; Sobel 1.0ThresholdSave edge image BlocksMove to larger blocks \/ pixelateEnhance -&gt; DespeckleSave block imag Inkscape for edge findingExtensions -&gt; Modify path -&gt; Flatten beziers 2.0Gives one path with all segmentsPath -&gt; Break Apart. Check, clean [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1316,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1328","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1328"}],"version-history":[{"count":13,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1328\/revisions"}],"predecessor-version":[{"id":1705,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1328\/revisions\/1705"}],"up":[{"embeddable":true,"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1316"}],"wp:attachment":[{"href":"http:\/\/jimlund.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}