MATLAB is an awesome tool for image processing and analysis; one feature that puts it head and shoulders above the rest is it’s ability to represent images as a matrix. With this capability we can leverage our knowledge of Linear Algebra and Calculus to do some pretty amazing things. This use of matrices also allows us to intuitively perform some simple functions such as cutting an image into multiple pieces.
To do this we first load an image into MATLAB using the imread command.
waldo = imread('http://www.findwaldo.com/fankit/graphics/IntlManOfLiterature/Scenes/AtTheBeach.jpg'); imshow(waldo);
To take just a block of the image for further analysis by either an image recognition algorithm, neural net, or some other function we would use this code.
where imshow(xLbound : xUbound, yLbound : yUbound, : ) we take the entire row and column for the last parameter to preserve the colour of the image. See if you can identify where the slice came from. 🙂