{"id":2463,"date":"2019-08-02T10:01:04","date_gmt":"2019-08-01T22:01:04","guid":{"rendered":"http:\/\/blogs.lincoln.ac.nz\/gis\/?p=2463"},"modified":"2023-05-07T03:22:08","modified_gmt":"2023-05-07T03:22:08","slug":"the-paint-by-number-tool","status":"publish","type":"post","link":"https:\/\/blogs.lincoln.ac.nz\/gis\/the-paint-by-number-tool\/","title":{"rendered":"The Paint-By-Number Tool"},"content":{"rendered":"<p><em>We can use remotely sensed images to extract useful information about the land surface using image classification.\u00a0 The first step is usually\u00a0segmentation, which groups pixels with common properties together.\u00a0 This post is a quick look at what it is and how to do it.<\/em><\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-numbers.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2473\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-numbers.jpg\" alt=\"\" width=\"1000\" height=\"719\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-numbers.jpg 1000w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-numbers-300x216.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-numbers-768x552.jpg 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p>Ah, a nice, relaxing paint-by-numbers landscape for a Friday.\u00a0 While I&#8217;d love to while away a few hours doing one of these myself, our subject today is image segmentation, but I&#8217;ve started with this due to that unique aesthetic quality we often see in paint-by-number works; we&#8217;ll come back to that later.<\/p>\n<p>We&#8217;ve been looking at <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/wavelengths\/\" target=\"_blank\" rel=\"noopener noreferrer\">remotely sensed images<\/a> recently and using things like <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/the-grass-is-always-greener-isnt-it\/\" target=\"_blank\" rel=\"noopener noreferrer\">NDVI<\/a> to glean some useful information from the raw data.\u00a0 In this post we\u00a0delving into the process of image analysis, or more specifically, image classification.\u00a0 This is the process of converting the data in an image into useful data layers, such as land cover or impervious surfaces.\u00a0 A really good example of an output from image classification is the <a href=\"https:\/\/lris.scinfo.org.nz\/layer\/48423-lcdb-v41-land-cover-database-version-41-mainland-new-zealand\/\" target=\"_blank\" rel=\"noopener noreferrer\">Land Cover Database,<\/a>\u00a0a polygon layer with 33 different classes of land cover for the whole country (including the Chathams) at a scale of 1:50,000.\u00a0 Here&#8217;s an image from the lyttle town of Lyttelton and surrounding area to give you a sense of some of the land cover classes and scale:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/LytLCDB.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2464\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/LytLCDB.jpg\" alt=\"\" width=\"1168\" height=\"706\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/LytLCDB.jpg 1168w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/LytLCDB-300x181.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/LytLCDB-1024x619.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/LytLCDB-768x464.jpg 768w\" sizes=\"auto, (max-width: 1168px) 100vw, 1168px\" \/><\/a><\/p>\n<p>This layer began life as a set of satellite images.\u00a0 Using <a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/tool-reference\/image-analyst\/understanding-segmentation-and-classification.htm\" target=\"_blank\" rel=\"noopener noreferrer\">image classification<\/a>, pixels were reclassified to a specific land cover on a national scale and then converted over to polygons.\u00a0 Sounds pretty straightforward but there&#8217;s as much art as science that goes into the process.<\/p>\n<p>One key first step in\u00a0a process like this is image segmentation.\u00a0\u00a0With segmentation, pixels with similar characteristics are grouped together into segments, which is really nothing more than putting a pixel into a bin, or class, with other pixels that have similar values.\u00a0 When you fill out a census form, for example, you&#8217;re sort of segmenting yourself based on your personal details: age, income, level of education, whether you&#8217;re a Jedi or not, etc.\u00a0 Each detail goes into\u00a0a bin and later we can make some judgments about what those bins tell us about you (in my case, I think it means I&#8217;m in the rubbish bin&#8230;). With an image, we\u00a0go right back to the intensity values for each pixel in each band (what we might also call its spectral values), so the more bands you have, the better job you can do of segmenting an image.\u00a0 At the end of the segmentation process we won&#8217;t have our land cover classes but it will make the steps that follow a lot easier.<\/p>\n<p><strong>How to Segment<\/strong><\/p>\n<p>We&#8217;ll go back to our Mt Grand image to illustrate segmentation, here added to a map in Pro:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/MtGinPro.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2465\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/MtGinPro.jpg\" alt=\"\" width=\"1436\" height=\"854\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/MtGinPro.jpg 1436w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/MtGinPro-300x178.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/MtGinPro-1024x609.jpg 1024w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/MtGinPro-768x457.jpg 768w\" sizes=\"auto, (max-width: 1436px) 100vw, 1436px\" \/><\/a><\/p>\n<p>As we&#8217;ve seen before, this is a four band image with a band for Blue, Green, Red and Infrared.\u00a0 To do land cover mapping that&#8217;s the bare minimum.\u00a0 You can do it with an RGB image but the result won&#8217;t be nearly as reliable &#8211; the infrared band <a href=\"http:\/\/blogs.lincoln.ac.nz\/gis\/the-grass-is-always-greener-isnt-it\/\" target=\"_blank\" rel=\"noopener noreferrer\">adds a lot of value<\/a>.\u00a0 As shown\u00a0above, I&#8217;m looking on the Imagery tab and will use the<a href=\"https:\/\/pro.arcgis.com\/en\/pro-app\/help\/analysis\/image-analyst\/segmentation.htm\" target=\"_blank\" rel=\"noopener noreferrer\"> Segmentation<\/a> tool under Classification Tools:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2466 alignleft\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool.jpg\" alt=\"\" width=\"371\" height=\"335\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool.jpg 371w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool-300x271.jpg 300w\" sizes=\"auto, (max-width: 371px) 100vw, 371px\" \/><\/a>\u00a0The other two tools we&#8217;ll use in a later post.<\/p>\n<p>After clicking on Segmentation a new pane should open at the right &#8211; we&#8217;ll need to set some <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/product\/national-government\/pass-the-classification-but-hold-the-salt-and-pepper\/\" target=\"_blank\" rel=\"noopener noreferrer\">parameters<\/a>:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2467 alignright\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool2.jpg\" alt=\"\" width=\"263\" height=\"369\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool2.jpg 263w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SegTool2-214x300.jpg 214w\" sizes=\"auto, (max-width: 263px) 100vw, 263px\" \/><\/a><\/p>\n<p>Spectral Detail sets the level of importance given to differences between features you want to distinguish.\u00a0 Values range between 1 and 20.\u00a0 The higher the value, the more you can distinguish between features.\u00a0 Lower values result in fewer segments (and, oddly enough, longer processing times).<\/p>\n<p>Spatial detail ranges from 1 to 20; the higher the number, the more importance you can place on combining segments\u00a0that are close together.<\/p>\n<p>The Minimum segment size in pixels allows you set the minimum size of any segment (though not its shape).\u00a0 Segments smaller than this size are forced into the best fitting segment close by.\u00a0 Of course how large this area will be in real life depends on the resolution of the image.<\/p>\n<p>These would usually be a fair bit of trial and error in getting the right segmentation as these settings directly depend on how much detail you&#8217;re wanting to map.\u00a0 For this post, we&#8217;ll just stick with the defaults.\u00a0 Here&#8217;s the result, zoomed in to an area so you can see the effect &#8211; I&#8217;ve put the original image and the segmented one side by side so you can more easily see the output:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2468\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide.jpg\" alt=\"\" width=\"693\" height=\"304\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide.jpg 693w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide-300x132.jpg 300w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/a><\/p>\n<p>They look quite similar, I hear you say.\u00a0 I&#8217;ll zoom in some more to tease out the differences:<\/p>\n<p><a href=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2469\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide2.jpg\" alt=\"\" width=\"698\" height=\"351\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide2.jpg 698w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/SideBySide2-300x151.jpg 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/a><\/p>\n<p>On the left we can see all the detail from the original image, but it&#8217;s more generalised and smoothed out on the right.\u00a0 This is where the paint-by-number picture comes back.\u00a0 Looking at segmented images, I&#8217;m often reminded of that slightly abstracted effect, like\u00a0someone has painstakingly painted within the lines with just a few colours.\u00a0\u00a0We can visually interpret what the land covers are on the right (including shadows) and hopefully you can see how groups of similar pixels are now together.\u00a0 These are the segments.\u00a0 We could go back and tweak the settings to end up with fewer or more segments but the key thing we&#8217;ve accomplished here is to simplify the original image using the details from the individual bands.\u00a0 Now instead of dealing with individual pixels, we&#8217;re dealing with zones of pixels with similar values.<\/p>\n<p>You might be tempted to think our job is done here, but this is really the first step towards land cover mapping.\u00a0 While the pixels have been grouped together we still don&#8217;t know what they represent.\u00a0 Well, at least Pro doesn&#8217;t.\u00a0 Our wetware\u00a0can quickly do\u00a0the visual interpretation and have a pretty good idea about what&#8217;s what.\u00a0 But for this to be a useful, permanent layer for analysis and mapping, we&#8217;ve got to go to the next step of image classification.\u00a0 And we&#8217;re going to want to do the whole image at one time and not just smaller sections.\u00a0 It&#8217;s a fairly involved process so stay tuned &#8211; we&#8217;ll cover it soon.<\/p>\n<p>In the meantime, grab your favourite paint-by-numbers kit and start relaxing.\u00a0 Here&#8217;s mine:<\/p>\n<figure id=\"attachment_2472\" aria-describedby=\"caption-attachment-2472\" style=\"width: 750px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/mymodernmet.com\/paint-by-numbers-kits\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2472 size-full\" src=\"https:\/\/d-blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-number-6.jpg\" alt=\"\" width=\"750\" height=\"750\" srcset=\"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-number-6.jpg 750w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-number-6-300x300.jpg 300w, https:\/\/blogs.lincoln.ac.nz\/gis\/wp-content\/uploads\/sites\/3\/2019\/08\/paint-by-number-6-150x150.jpg 150w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/a><figcaption id=\"caption-attachment-2472\" class=\"wp-caption-text\">https:\/\/mymodernmet.com\/paint-by-numbers-kits\/<\/figcaption><\/figure>\n<p>C<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We can use remotely sensed images to extract useful information about the land surface using image classification.\u00a0 The first step is usually\u00a0segmentation, which groups pixels with common properties together.\u00a0 This post is a quick look at what it is and how to do it. Ah, a nice, relaxing paint-by-numbers landscape for a Friday.\u00a0 While I&#8217;d [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2463","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/2463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/comments?post=2463"}],"version-history":[{"count":1,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/2463\/revisions"}],"predecessor-version":[{"id":4107,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/posts\/2463\/revisions\/4107"}],"wp:attachment":[{"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/media?parent=2463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/categories?post=2463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.lincoln.ac.nz\/gis\/wp-json\/wp\/v2\/tags?post=2463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}