4275
How the DILATE function works on a grayscale image.
This Help Article walks through the operations performed by the DILATE routine.
Discussion
Let A be the following array:

Define S to be the following structuring element with origin at element (1,1):

The origin of the structuring element, denoted as O, is systematically placed over each pixel in the image, with the exception of image pixels which result in a portion of the structuring element outside of the image (entries (0,0), (0,1), (0,2), (0,3), (1,0), (2,0) and (3,0) in this example), and then used to determine potential new values for the pixels under the remaining elements of the structuring element. Note that the final value of a pixel is not being determined; Just potential values for the final output.
In this example, O is first placed over A[1,1] (The position of the structuring element is boldfaced with O's position underlined).

Placing O over A[2,1], we get more potential pixel values.

Continuing this process over A[i,j], 1 <= i <= 3, 1 <= j <= 2, we get the following potential pixel values:

The next pixel over which O will be placed is A[1,3] = 0. Since this pixel value is 0, no new potential pixel values will be added to the sets for A[0,2], A[1,2], A[0,3] and A[1,3]. Since all of image pixel values are non-negative in this case, 0 will be added to each set:

Placing O over the remaining two image pixels (A[2,3] and A[3,3]), we get the following array of potential pixel values.

Picking the maximum from each set, we get the output from DIALTE:

This result can be verified using IDL:
IDL> a = [[2,3,4,1],[0,5,7,2],[1,8,4,5],[6,0,9,3]]
IDL> s = [[1,1],[0,1]]
IDL> print, dilate(a,s, /gray)
5 7 7 2
8 8 7 5
0 9 9 5
0 0 9 3