Search code examples
arraysimagematlabimage-processinghexdump

How to Get pixel Intensity Values Matrix


I want to get the closer look of images pixels and also the pixel value matrix (which usually ranges 255 integer values I think). Do I need Matlab, or any other program/framework? (I am a Computer Science Student)

Attached a screenshot of what exactly I want (copied from http://www.whydomath.org/node/wavlets/imagebasics.html):

snapshot

Want you help, Thanks!


Solution

  • You can read an image (like this one) from disk and display it on the screen in Matlab as follows:

    >> img = imread('lion.png');
    >> imshow(img)
    

    lion

    To get a closeup you just need to define the specific region you are interested in like so:

    >> upper = 60;
    >> lower = 100;
    >> left = 40;
    >> right = 80;
    >> imshow(img(upper:lower, left:right))
    

    face

    Finally, you can also display the intensity values of a particular region of the image by simply typing:

    >> row_min = 75;
    >> row_max = 80;
    >> col_min = 55;
    >> col_max = 60;
    >> img(row_min:row_max, col_min:col_max)
    
    ans =
    
      159  199  180  184  181  168
      154  157  163  175  172  155
      158  135  143  156  167  149
      124  132  124  147  178  158
      126  138  123  145  178  159
      131  140  137  141  155  146