Page 205 - MATLAB Recipes for Earth Sciences
P. 205

200                                                 8 Image Processing

            reads and decompresses the JPEG fi le, and imports the data as 24-bit RGB
            image array and stores the data in a variable unconform1. The command

               whos

            shows how the  RGB array is stored in the workspace:
               Name          Size          Bytes         Class
               unconform1    729x713x3     1559331       uint8 array
               Grand total is 1559331 elements using 1559331 bytes
            The details indicate that the image is stored as a 729x713x3 array represent-
            ing a 729x713 array for each of the colors red, green and blue. The listing of
            the current variables in the workspace also gives the information uint8 array,
            i.e., each array element representing one pixel contains 8-bit integers. These
            integers represent intensity values between 0 (minimum intensity) and 255
            (maximum). As example, here is a sector in the upper-left corner of the data
            array for red:

               unconform1(50:55,50:55,1)
               ans =
                  174 177 180 182 182 182
                  165 169 170 168 168 170
                  171 174 173 168 167 170
                  184 186 183 177 174 176
                  191 192 190 185 181 181
                  189 190 190 188 186 183
            Next we can view the image using the command

                 imshow(unconform1)

            which opens a new Figure Window showing a RGB composite of the image
            (Fig. 8.1).
               In contrast to the RGB image, a grayscale image only needs one single
            array to store all necessary information. We convert the RBG image into a
            grayscale image using the command rgb2gray (RGB to gray):

               unconform2 = rgb2gray (unconform1);
            The new workspace listing now reads:

               Name          Size          Bytes         Class
               unconform1    729x713x3     1559331       uint8 array
               unconform2    729x713       519777        uint8 array
               Grand total is 2079108 elements using 2079108 bytes
            where you can see the difference between the 24-bit RGB and the 8-bit gray-
   200   201   202   203   204   205   206   207   208   209   210