{"id":31,"date":"2006-01-27T07:00:17","date_gmt":"2006-01-27T12:00:17","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=31"},"modified":"2022-05-29T18:51:16","modified_gmt":"2022-05-29T22:51:16","slug":"all-about-pixel-colors","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2006\/01\/27\/all-about-pixel-colors\/","title":{"rendered":"All about pixel colors"},"content":{"rendered":"<div class=\"alert alert-info\">\r\n<span class=\"alert_icon icon-alert-info-reverse\"><\/span>\r\n<p class=\"alert_heading\"><strong>Note<\/strong><\/p>\r\n<p>See the following posts for new or updated information about this topic:<\/p>\r\n<li><a href=\"https:\/\/blogs.mathworks.com\/steve\/2016\/02\/09\/matlab-image-display-from-data-values-to-pixel-colors\/\">MATLAB image display - from data values to pixel colors<\/a><\/li>\r\n<li><a href=\"https:\/\/blogs.mathworks.com\/steve\/2016\/02\/22\/matlab-image-display-truecolor-and-indexed-images\/\">MATLAB image display - truecolor and indexed images<\/a><\/li>\r\n<li><a href=\"https:\/\/blogs.mathworks.com\/steve\/2016\/02\/29\/matlab-image-display-scaled-indexed-images\/\">MATLAB image display - scaled indexed images<\/a><\/li>\r\n<li><a href=\"https:\/\/blogs.mathworks.com\/steve\/2016\/03\/14\/matlab-image-display-grayscale-and-binary-images\/\">MATLAB image display - grayscale and binary images<\/a><\/li>\r\n<li>MATLAB image display - autoscaling values with imshow<\/li>\r\n<\/div>\r\n\r\n<p>\r\nTell me, quick: What are the colors of these pixel values?\r\n<\/p>\r\n\r\n<p>\r\n<table>\r\n<tr>\r\n<td> 252 <\/td> <td> 249 <\/td> <td> 246 <\/td> <td> 243 <\/td> <td> 237 <\/td>\r\n<\/tr>\r\n<tr>\r\n<td> 255 <\/td> <td> 255 <\/td> <td> 250 <\/td> <td> 246 <\/td> <td> 243 <\/td>\r\n<\/tr>\r\n<tr>\r\n<td> 253 <\/td> <td> 254 <\/td> <td> 248 <\/td> <td> 245 <\/td> <td> 243 <\/td>\r\n<\/tr>\r\n<tr>\r\n<td> 250 <\/td> <td> 249 <\/td> <td> 245 <\/td> <td> 243 <\/td> <td> 239 <\/td>\r\n<\/tr>\r\n<\/table>\r\n<\/p>\r\n\r\n<p>\r\nThe colors are white and near-white, right?\r\n<\/p>\r\n\r\n<p>\r\nOK, sorry, that was a trick question.  These values aren't taken from a\r\npicture at all.  They are digital elevation values for locations near\r\nBoston.  I downloaded the data file from the U.S. Geological Survey web site and\r\nread it into MATLAB using the <a href=\"https:\/\/www.mathworks.com\/products\/mapping\/\">Mapping Toolbox<\/a> function <tt>usgsdem<\/tt>.\r\n<\/p>\r\n\r\n<p>\r\nStill, you could certainly display the data set as an image using MATLAB.\r\nIt might look like this:\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/31\/dem_snippet_gray.png\" \/>\r\n<\/p>\r\n\r\n<p>\r\nOr maybe like this:\r\n<\/p>\r\n\r\n<p>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/31\/dem_snippet_color.png\" \/>\r\n<\/p>\r\n\r\n<p>\r\nWhich brings me back to my original question, which I'd like to rephrase:\r\nHow does MATLAB associate the value of a particular matrix element with a\r\ncolor displayed on the screen?\r\n<\/p>\r\n\r\n<p>\r\nI'm going to explore this question over the next few weeks.  Specific\r\ntopics will include:\r\n<\/p>\r\n\r\n<ul>\r\n<li> The two different pixel-color models in MATLAB. (Or maybe there are\r\nthree. It depends on how you count.) <\/li>\r\n<li> How properties of the figure, axes, and image objects all affect pixel\r\ncolors. <\/li>\r\n<li> Additional pixel-color models in the Image Processing Toolbox. <\/li>\r\n<li> The MATLAB and Image Processing Toolbox image display functions and how they\r\nwork. <\/li>\r\n<\/ul>\r\n\r\n<h4> A Blog Note<\/h4>\r\n\r\n<p>\r\nAs an experiment, I plan to interleave postings about the pixel-color topic\r\nwith postings about the <a\r\nhref=\"https:\/\/blogs.mathworks.com\/steve\/?p=22\">spatial transformations\r\ntopic<\/a> that I mentioned earlier this week.  I'm trying to find a\r\ncompromise between taking the time to explore a specific topic in depth,\r\nand providing material that interests a variety of readers.\r\n<\/p>\r\n\r\n<p>\r\nWe'll see how it goes.  As always, feedback is welcome.  Please leave a\r\ncomment!\r\n<\/p>","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nNote\r\nSee the following posts for new or updated information about this topic:\r\nMATLAB image display - from data values to pixel colors\r\nMATLAB image display - truecolor and indexed... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2006\/01\/27\/all-about-pixel-colors\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/31"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":5537,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/31\/revisions\/5537"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}