{"id":1919,"date":"2019-03-24T18:00:19","date_gmt":"2019-03-24T18:00:19","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2019\/03\/24\/how-to-manually-scale-image-pixel-data-for-deep-learning\/"},"modified":"2019-03-24T18:00:19","modified_gmt":"2019-03-24T18:00:19","slug":"how-to-manually-scale-image-pixel-data-for-deep-learning","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2019\/03\/24\/how-to-manually-scale-image-pixel-data-for-deep-learning\/","title":{"rendered":"How to Manually Scale Image Pixel Data for Deep Learning"},"content":{"rendered":"<p>Author: Jason Brownlee<\/p>\n<div>\n<p>Images are comprised of matrices of pixel values.<\/p>\n<p>Black and white images are single matrix of pixels, whereas color images have a separate array of pixel values for each color channel, such as red, green, and blue.<\/p>\n<p>Pixel values are often unsigned integers in the range between 0 and 255. Although these pixel values can be presented directly to neural network models in their raw format, this can result in challenges during modeling, such as in the slower than expected training of the model.<\/p>\n<p>Instead, there can be great benefit in preparing the image pixel values prior to modeling, such as simply scaling pixel values to the range 0-1 to centering and even standardizing the values.<\/p>\n<p>In this tutorial, you will discover image data for modeling with deep learning neural networks.<\/p>\n<p>After completing this tutorial, you will know:<\/p>\n<ul>\n<li>How to normalize pixel values to a range between zero and one.<\/li>\n<li>How to center pixel values both globally across channels and locally per channel.<\/li>\n<li>How to standardize pixel values and how to shift standardized pixel values to the positive domain.<\/li>\n<\/ul>\n<p>Let\u2019s get started.<\/p>\n<h2>Tutorial Overview<\/h2>\n<p>This tutorial is divided into four parts; they are:<\/p>\n<ol>\n<li>Sample Image<\/li>\n<li>Normalize Pixel Values<\/li>\n<li>Center Pixel Values<\/li>\n<li>Standardize Pixel Values<\/li>\n<\/ol>\n<h2>Sample Image<\/h2>\n<p>We need a sample image for testing in this tutorial.<\/p>\n<p>We will use a photograph of the <a href=\"https:\/\/www.flickr.com\/photos\/volvob12b\/27318376851\/\">Sydney Harbor Bridge<\/a> taken by \u201c<em>Bernard Spragg. NZ<\/em>\u201d and released under a permissive license.<\/p>\n<div id=\"attachment_7360\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7360\" class=\"size-full wp-image-7360\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge.jpg\" alt='Sydney Harbor Bridge taken by \"Bernard Spragg. NZ\"' width=\"640\" height=\"374\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge.jpg 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-300x175.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-7360\" class=\"wp-caption-text\">Sydney Harbor Bridge taken by \u201cBernard Spragg. NZ\u201d<br \/>Some rights reserved.<\/p>\n<\/div>\n<p>Download the photograph and place it into your current working directory with the filename \u201c<em>sydney_bridge.jpg<\/em>\u201c.<\/p>\n<ul>\n<li><a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-Photograph-Loaded-From-File.png\">Click to Download the Photograph (sydney_bridge.jpg)<\/a><\/li>\n<\/ul>\n<p>The example below will load the image, display some properties about the loaded image, then show the image.<\/p>\n<p>This example and the rest of the tutorial assumes that you have the Pillow Python library installed.<\/p>\n<pre class=\"crayon-plain-tag\"># load and show an image with Pillow\r\nfrom PIL import Image\r\n# load the image\r\nimage = Image.open('sydney_bridge.jpg')\r\n# summarize some details about the image\r\nprint(image.format)\r\nprint(image.mode)\r\nprint(image.size)\r\n# show the image\r\nimage.show()<\/pre>\n<p>Running the example reports the format of the image, which is JPEG, and the mode, which is RGB for the three color channels.<\/p>\n<p>Next, the size of the image is reported, showing 640 pixels in width and 374 pixels in height.<\/p>\n<pre class=\"crayon-plain-tag\">JPEG\r\nRGB\r\n(640, 374)<\/pre>\n<p>The image is then previewed using the default application for showing images on your workstation.<\/p>\n<div id=\"attachment_7361\" style=\"width: 1290px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7361\" class=\"size-full wp-image-7361\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-Photograph-Loaded-From-File.png\" alt=\"The Sydney Harbor Bridge Photograph Loaded From File\" width=\"1280\" height=\"856\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-Photograph-Loaded-From-File.png 1280w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-Photograph-Loaded-From-File-300x201.png 300w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-Photograph-Loaded-From-File-768x514.png 768w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/01\/The-Sydney-Harbor-Bridge-Photograph-Loaded-From-File-1024x685.png 1024w\" sizes=\"(max-width: 1280px) 100vw, 1280px\"><\/p>\n<p id=\"caption-attachment-7361\" class=\"wp-caption-text\">The Sydney Harbor Bridge Photograph Loaded From File<\/p>\n<\/div>\n<h2>Normalize Pixel Values<\/h2>\n<p>For most image data, the pixel values are integers with values between 0 and 255.<\/p>\n<p>Neural networks process inputs using small weight values, and inputs with large integer values can disrupt or slow down the learning process. As such it is good practice to normalize the pixel values so that each pixel value has a value between 0 and 1.<\/p>\n<p>It is valid for images to have pixel values in the range 0-1 and images can be viewed normally.<\/p>\n<p>This can be achieved by dividing all pixels values by the largest pixel value; that is 255. This is performed across all channels, regardless of the actual range of pixel values that are present in the image.<\/p>\n<p>The example below loads the image and converts it into a NumPy array. The data type of the array is reported and the minimum and maximum pixels values across all three channels are then printed. Next, the array is converted to the float data type before the pixel values are normalized and the new range of pixel values is reported.<\/p>\n<pre class=\"crayon-plain-tag\"># example of pixel normalization\r\nfrom numpy import asarray\r\nfrom PIL import Image\r\n# load image\r\nimage = Image.open('sydney_bridge.jpg')\r\npixels = asarray(image)\r\n# confirm pixel range is 0-255\r\nprint('Data Type: %s' % pixels.dtype)\r\nprint('Min: %.3f, Max: %.3f' % (pixels.min(), pixels.max()))\r\n# convert from integers to floats\r\npixels = pixels.astype('float32')\r\n# normalize to the range 0-1\r\npixels \/= 255.0\r\n# confirm the normalization\r\nprint('Min: %.3f, Max: %.3f' % (pixels.min(), pixels.max()))<\/pre>\n<p>Running the example prints the data type of the NumPy array of pixel values, which we can see is an 8-bit unsigned integer.<\/p>\n<p>The min and maximum pixel values are printed, showing the expected 0 and 255 respectively. The pixel values are normalized and the new minimum and maximum of 0.0 and 1.0 are then reported.<\/p>\n<pre class=\"crayon-plain-tag\">Data Type: uint8\r\nMin: 0.000, Max: 255.000\r\nMin: 0.000, Max: 1.000<\/pre>\n<p>Normalization is a good default data preparation that can be performed if you are in doubt as to the type of data preparation to perform.<\/p>\n<p>It can be performed per image and does not require the calculation of statistics across the training dataset, as the range of pixel values is a domain standard.<\/p>\n<h2>Center Pixel Values<\/h2>\n<p>A popular data preparation technique for image data is to subtract the mean value from the pixel values.<\/p>\n<p>This approach is called centering, as the distribution of the pixel values is centered on the value of zero.<\/p>\n<p>Centering can be performed before or after normalization. Centering the pixels then normalizing will mean that the pixel values will be centered close to 0.5 and be in the range 0-1. Centering after normalization will mean that the pixels will have positive and negative values, in which case images will not display correctly (e.g. pixels are expected to have value in the range 0-255 or 0-1). Centering after normalization might be preferred, although it might be worth testing both approaches.<\/p>\n<p>Centering requires that a mean pixel value be calculated prior to subtracting it from the pixel values. There are multiple ways that the mean can be calculated; for example:<\/p>\n<ul>\n<li>Per image.<\/li>\n<li>Per mini-batch of images (under stochastic gradient descent).<\/li>\n<li>Per training dataset.<\/li>\n<\/ul>\n<p>The mean can be calculated for all pixels in the image, referred to as a global centering, or it can be calculated for each channel in the case of color images, referred to as local centering.<\/p>\n<ul>\n<li><strong>Global Centering<\/strong>: Calculating and subtracting the mean pixel value across color channels.<\/li>\n<li><strong>Local Centering<\/strong>: Calculating and subtracting the mean pixel value per color channel.<\/li>\n<\/ul>\n<p>Per-image global centering is common because it is trivial to implement. Also common is per mini-batch global or local centering for the same reason: it is fast and easy to implement.<\/p>\n<p>In some cases, per-channel means are pre-calculated across an entire training dataset. In this case, the image means must be stored and used both during training and any inference with the trained models in the future. For example, the per-channel pixel means calculated for the ImageNet training dataset are as follows:<\/p>\n<ul>\n<li><strong>ImageNet Training Dataset Means<\/strong>: [0.485, 0.456, 0.406]<\/li>\n<\/ul>\n<p>For models trained on images centered using these means that may be used for transfer learning on new tasks, it can be beneficial or even required to normalize images for the new task using the same means.<\/p>\n<p>Let\u2019s look at a few examples.<\/p>\n<h3>Global Centering<\/h3>\n<p>The example below calculates a global mean across all three color channels in the loaded image, then centers the pixel values using the global mean.<\/p>\n<pre class=\"crayon-plain-tag\"># example of global centering (subtract mean)\r\nfrom numpy import asarray\r\nfrom PIL import Image\r\n# load image\r\nimage = Image.open('sydney_bridge.jpg')\r\npixels = asarray(image)\r\n# convert from integers to floats\r\npixels = pixels.astype('float32')\r\n# calculate global mean\r\nmean = pixels.mean()\r\nprint('Mean: %.3f' % mean)\r\nprint('Min: %.3f, Max: %.3f' % (pixels.min(), pixels.max()))\r\n# global centering of pixels\r\npixels = pixels - mean\r\n# confirm it had the desired effect\r\nmean = pixels.mean()\r\nprint('Mean: %.3f' % mean)\r\nprint('Min: %.3f, Max: %.3f' % (pixels.min(), pixels.max()))<\/pre>\n<p>Running the example, we can see that the mean pixel value is about 152.<\/p>\n<p>Once centered, we can confirm that the new mean for the pixel values is 0.0 and that the new data range is negative and positive around this mean.<\/p>\n<pre class=\"crayon-plain-tag\">Mean: 152.149\r\nMin: 0.000, Max: 255.000\r\nMean: -0.000\r\nMin: -152.149, Max: 102.851<\/pre>\n<\/p>\n<h3>Local Centering<\/h3>\n<p>The example below calculates the mean for each color channel in the loaded image, then centers the pixel values for each channel separately.<\/p>\n<p>Note that NumPy allows us to specify the dimensions over which a statistic like the mean, min, and max are calculated via the \u201c<em>axis<\/em>\u201d argument. In this example, we set this to (0,1) for the width and height dimensions, which leaves the third dimension or channels. The result is one mean, min, or max for each of the three channel arrays.<\/p>\n<p>Also note that when we calculate the mean that we specify the dtype as \u2018<em>float64<\/em>\u2018; this is required as it will cause all sub-operations of the mean, such as the sum, to be performed with 64-bit precision. Without this, the sum will be performed at lower resolution and the resulting mean will be wrong given the accumulated errors in the loss of precision, in turn meaning the mean of the centered pixel values for each channel will not be zero (or a very small number close to zero).<\/p>\n<pre class=\"crayon-plain-tag\"># example of per-channel centering (subtract mean)\r\nfrom numpy import asarray\r\nfrom PIL import Image\r\n# load image\r\nimage = Image.open('sydney_bridge.jpg')\r\npixels = asarray(image)\r\n# convert from integers to floats\r\npixels = pixels.astype('float32')\r\n# calculate per-channel means and standard deviations\r\nmeans = pixels.mean(axis=(0,1), dtype='float64')\r\nprint('Means: %s' % means)\r\nprint('Mins: %s, Maxs: %s' % (pixels.min(axis=(0,1)), pixels.max(axis=(0,1))))\r\n# per-channel centering of pixels\r\npixels -= means\r\n# confirm it had the desired effect\r\nmeans = pixels.mean(axis=(0,1), dtype='float64')\r\nprint('Means: %s' % means)\r\nprint('Mins: %s, Maxs: %s' % (pixels.min(axis=(0,1)), pixels.max(axis=(0,1))))<\/pre>\n<p>Running the example first reports the mean pixels values for each channel, as well as the min and max values for each channel. The pixel values are centered, then the new means and min\/max pixel values across each channel are reported.<\/p>\n<p>We can see that the new mean pixel values are very small numbers close to zero and the values are negative and positive values centered on zero.<\/p>\n<pre class=\"crayon-plain-tag\">Means: [148.61581718 150.64154412 157.18977691]\r\nMins: [0. 0. 0.], Maxs: [255. 255. 255.]\r\nMeans: [1.14413078e-06 1.61369515e-06 1.37722619e-06]\r\nMins: [-148.61581 -150.64154 -157.18977], Maxs: [106.384186 104.35846 97.81023 ]<\/pre>\n<\/p>\n<h2>Standardize Pixel Values<\/h2>\n<p>The distribution of pixel values often follows a <a href=\"https:\/\/machinelearningmastery.com\/statistical-data-distributions\/\">Normal or Gaussian distribution, e.g. bell shape<\/a>.<\/p>\n<p>This distribution may be present per image, per mini-batch of images, or across the training dataset and globally or per channel.<\/p>\n<p>As such, there may be benefit in transforming the distribution of pixel values to be a standard Gaussian: that is both centering the pixel values on zero and normalizing the values by the standard deviation. The result is a standard Gaussian of pixel values with a mean of 0.0 and a standard deviation of 1.0.<\/p>\n<p>As with centering, the operation can be performed per image, per mini-batch, and across the entire training dataset, and it can be performed globally across channels or locally per channel.<\/p>\n<p>Standardization may be preferred to normalization and centering alone and it results in both zero-centered values of small input values, roughly in the range -3 to 3, depending on the specifics of the dataset.<\/p>\n<p>For consistency of the input data, it may make more sense to standardize images per-channel using statistics calculated per mini-batch or across the training dataset, if possible.<\/p>\n<p>Let\u2019s look at some examples.<\/p>\n<h3>Global Standardization<\/h3>\n<p>The example below calculates the mean and standard deviation across all color channels in the loaded image, then uses these values to standardize the pixel values.<\/p>\n<pre class=\"crayon-plain-tag\"># example of global pixel standardization\r\nfrom numpy import asarray\r\nfrom PIL import Image\r\n# load image\r\nimage = Image.open('sydney_bridge.jpg')\r\npixels = asarray(image)\r\n# convert from integers to floats\r\npixels = pixels.astype('float32')\r\n# calculate global mean and standard deviation\r\nmean, std = pixels.mean(), pixels.std()\r\nprint('Mean: %.3f, Standard Deviation: %.3f' % (mean, std))\r\n# global standardization of pixels\r\npixels = (pixels - mean) \/ std\r\n# confirm it had the desired effect\r\nmean, std = pixels.mean(), pixels.std()\r\nprint('Mean: %.3f, Standard Deviation: %.3f' % (mean, std))<\/pre>\n<p>Running the example first calculates the global mean and standard deviation pixel values, standardizes the pixel values, then confirms the transform by reporting the new global mean and standard deviation of 0.0 and 1.0 respectively.<\/p>\n<pre class=\"crayon-plain-tag\">Mean: 152.149, Standard Deviation: 70.642\r\nMean: -0.000, Standard Deviation: 1.000<\/pre>\n<\/p>\n<h3>Positive Global Standardization<\/h3>\n<p>There may be a desire to maintain the pixel values in the positive domain, perhaps so the images can be visualized or perhaps for the benefit of a chosen activation function in the model.<\/p>\n<p>A popular way of achieving this is to clip the standardized pixel values to the range [-1, 1] and then rescale the values from [-1,1] to [0,1].<\/p>\n<p>The example below updates the global standardization example to demonstrate this additional rescaling.<\/p>\n<pre class=\"crayon-plain-tag\"># example of global pixel standardization shifted to positive domain\r\nfrom numpy import asarray\r\nfrom numpy import clip\r\nfrom PIL import Image\r\n# load image\r\nimage = Image.open('sydney_bridge.jpg')\r\npixels = asarray(image)\r\n# convert from integers to floats\r\npixels = pixels.astype('float32')\r\n# calculate global mean and standard deviation\r\nmean, std = pixels.mean(), pixels.std()\r\nprint('Mean: %.3f, Standard Deviation: %.3f' % (mean, std))\r\n# global standardization of pixels\r\npixels = (pixels - mean) \/ std\r\n# clip pixel values to [-1,1]\r\npixels = clip(pixels, -1.0, 1.0)\r\n# shift from [-1,1] to [0,1] with 0.5 mean\r\npixels = (pixels + 1.0) \/ 2.0\r\n# confirm it had the desired effect\r\nmean, std = pixels.mean(), pixels.std()\r\nprint('Mean: %.3f, Standard Deviation: %.3f' % (mean, std))\r\nprint('Min: %.3f, Max: %.3f' % (pixels.min(), pixels.max()))<\/pre>\n<p>Running the example first reports the global mean and standard deviation pixel values; the pixels are standardized then rescaled.<\/p>\n<p>Next, the new mean and standard deviation are reported of about 0.5 and 0.3 respectively and the new minimum and maximum values are confirmed of 0.0 and 1.0.<\/p>\n<pre class=\"crayon-plain-tag\">Mean: 152.149, Standard Deviation: 70.642\r\nMean: 0.510, Standard Deviation: 0.388\r\nMin: 0.000, Max: 1.000<\/pre>\n<\/p>\n<h3>Local Standardization<\/h3>\n<p>The example below calculates the mean and standard deviation of the loaded image per-channel, then uses these statistics to standardize the pixels separately in each channel.<\/p>\n<pre class=\"crayon-plain-tag\"># example of per-channel pixel standardization\r\nfrom numpy import asarray\r\nfrom PIL import Image\r\n# load image\r\nimage = Image.open('sydney_bridge.jpg')\r\npixels = asarray(image)\r\n# convert from integers to floats\r\npixels = pixels.astype('float32')\r\n# calculate per-channel means and standard deviations\r\nmeans = pixels.mean(axis=(0,1), dtype='float64')\r\nstds = pixels.std(axis=(0,1), dtype='float64')\r\nprint('Means: %s, Stds: %s' % (means, stds))\r\n# per-channel standardization of pixels\r\npixels = (pixels - means) \/ stds\r\n# confirm it had the desired effect\r\nmeans = pixels.mean(axis=(0,1), dtype='float64')\r\nstds = pixels.std(axis=(0,1), dtype='float64')\r\nprint('Means: %s, Stds: %s' % (means, stds))<\/pre>\n<p>Running the example first calculates and reports the means and standard deviation of the pixel values in each channel.<\/p>\n<p>The pixel values are then standardized and statistics are re-calculated, confirming the new zero-mean and unit standard deviation.<\/p>\n<pre class=\"crayon-plain-tag\">Means: [148.61581718 150.64154412 157.18977691], Stds: [70.21666738 70.6718887 70.75185228]\r\nMeans: [ 6.26286458e-14 -4.40909176e-14 -8.38046276e-13], Stds: [1. 1. 1.]<\/pre>\n<\/p>\n<h2>Extensions<\/h2>\n<p>This section lists some ideas for extending the tutorial that you may wish to explore.<\/p>\n<ul>\n<li><strong>Develop Function<\/strong>. Develop a function to scale a provided image, using arguments to choose the type of preparation to perform,<\/li>\n<li><strong>Projection Methods<\/strong>. Investigate and implement data preparation methods that remove linear correlations from the pixel data, such as PCA and ZCA.<\/li>\n<li><strong>Dataset Statistics<\/strong>. Select and update one of the centering or standardization examples to calculate statistics across an entire training dataset, then apply those statistics when preparing image data for training or inference.<\/li>\n<\/ul>\n<p>If you explore any of these extensions, I\u2019d love to know.<\/p>\n<h2>Further Reading<\/h2>\n<p>This section provides more resources on the topic if you are looking to go deeper.<\/p>\n<h3>API<\/h3>\n<ul>\n<li><a href=\"https:\/\/docs.scipy.org\/doc\/numpy\/reference\/generated\/numpy.mean.html\">numpy.mean API<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/numpy\/numpy\/issues\/8869\">numpy.mean along multiple axis gives wrong result for large arrays, Issue<\/a>.<\/li>\n<\/ul>\n<h3>Articles<\/h3>\n<ul>\n<li><a href=\"http:\/\/cs231n.github.io\/neural-networks-2\/\">Data Preprocessing, CS231n Convolutional Neural Networks for Visual Recognition<\/a><\/li>\n<li><a href=\"https:\/\/stats.stackexchange.com\/questions\/211436\/why-normalize-images-by-subtracting-datasets-image-mean-instead-of-the-current\">Why normalize images by subtracting dataset\u2019s image mean, instead of the current image mean in deep learning?<\/a><\/li>\n<li><a href=\"https:\/\/www.quora.com\/What-are-some-ways-of-pre-procesing-images-before-applying-convolutional-neural-networks-for-the-task-of-image-classification\">What are some ways of pre-processing images before applying convolutional neural networks for the task of image classification?<\/a><\/li>\n<li><a href=\"https:\/\/discuss.pytorch.org\/t\/confused-about-the-image-preprocessing-in-classification\/3965\">Confused about the image preprocessing in classification, Pytorch Issue<\/a>.<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>In this tutorial, you discovered how to prepare image data for modeling with deep learning neural networks.<\/p>\n<p>Specifically, you learned:<\/p>\n<ul>\n<li>How to normalize pixel values to a range between zero and one.<\/li>\n<li>How to center pixel values both globally across channels and locally per channel.<\/li>\n<li>How to standardize pixel values and how to shift standardized pixel values to the positive domain.<\/li>\n<\/ul>\n<p>Do you have any questions?<br \/>\nAsk your questions in the comments below and I will do my best to answer.<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/how-to-manually-scale-image-pixel-data-for-deep-learning\/\">How to Manually Scale Image Pixel Data for Deep Learning<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/\">Machine Learning Mastery<\/a>.<\/p>\n<\/div>\n<p><a href=\"https:\/\/machinelearningmastery.com\/how-to-manually-scale-image-pixel-data-for-deep-learning\/\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Jason Brownlee Images are comprised of matrices of pixel values. Black and white images are single matrix of pixels, whereas color images have a [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2019\/03\/24\/how-to-manually-scale-image-pixel-data-for-deep-learning\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[24],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/1919"}],"collection":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=1919"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/1919\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/1920"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=1919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=1919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=1919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}