|  Pixel 
Spatial Relationships

 IntroductionMATLAB provides several nice features to help you create interactive 
applications. The graphical input function ‘ginput’ reports pixel coordinates 
selected by the pointing device. Distance measures can be reported once your 
application prompts the user for two points on the image. MATLAB's high-level programming features can also be used to implement 
algorithms. In particular, you will create an application that can identify the 
individual four-connected regions in a binary image. Objectives
  |  | Design an interactive routine that reports various 
  distance measures between two selected pixels in an image |  |  | Implement the automated 4-connected region 
  identifier algorithm discussed in class |  DeliverablesOne-page memo detailing your results, plus additional attachments as 
needed. Be sure to include the following: 
  |  | Hardcopy of 
  all MATLAB code you develop |  |  | Hardcopy of 
  image and command line output demonstrating your distance measures script |  |  | Hardcopy of 
  image output from your four-connected region identifier |  The memo will be due at the next lab period. 
 Distance MeasuresCreate a script called ‘distance.m’ that prompts the user to select two 
pixels on a displayed image, and then displays the three distance measures 
discussed in class (Euclidean, city-block, and chessboard). Your script should 
place marks on the image to show the selected pixels. Useful MATLAB functions to consider include ‘ginput’, ‘disp’, ‘text’, and ‘sprintf’. Once you have completed your script, compare your results to the ‘pixval’ 
function (try holding down the left mouse button as you move the cursor). Region Identifier AlgorithmWe recently discussed an algorithm in class that can automatically identify 
four-connected regions in a binary image. Implement the algorithm in MATLAB (or 
another language, if you prefer). Test your algorithm using the ‘letters.png’ 
image. NOTE: You need to convert ‘letters.png’ to a binary image as follows: 
   m = imread('letters.png');
m = m > 128;The resulting image will have background pixels set to zero and foreground 
pixels to one. We used letters for the region identifiers when we tried the algorithm on a 
small image in class. This technique becomes impractical for larger images, 
however. Use numerical values for your region identifiers, i.e., the sequence 1, 
2, 3, etc. These symbols will be much easier to see if you assign distinct 
colors to each numerical value, and then use a color display. Recall that 
‘imshow’ can be called with a second argument containing a colormap. You can 
design your own colormap, or try using one of the built-in colormaps (see the 
help page on the ‘colormap’ function for more information). |