Image Processing Reference
Fig. 4.28 The order in which
the pixels are visited.
Illustrated for a 10 × 10
Remember that each pixel is individually processed meaning that it does not mat-
ter in which order the pixels are processed. However, we follow the order illustrated
in Fig. 4.28 . Starting in the upper-left corner we move from left to right and from
top to bottom ending in the lower-right corner. 5
Note that this order corresponds to the way the coordinate system is defined, see
Fig. 2.19. The reason for this order is that it corresponds to the order in which the
pixels from the camera are sent to the memory of the computer. Also the same order
the pixels on your TV are updated. Physically the pixels are also stored in this order
meaning that your algorithm is faster when you process the pixels in this order due
to memory access time.
In terms of programming the point processing operations can be implemented as
illustrated below—here exemplified in C-code:
(y = 0;
y < M;
y = y + 1)
(x = 0;
x < N;
x = x + 1)
GetPixel ( input ,
value = Operation (temp );
SetPixel ( output ,
where M is the height of the image and N is the width of the image. GetPixel
is a function, which returns the value of the pixel at position (x, y) in the image
called input . The function SetPixel changes the value of the pixel at position (x, y)
in the image called output to value . Note that the two functions are not built-in C-
functions. That is, you either need to write them yourself or include a library where
they (or similar functions) are defined.
5 Note that the above order of scanning through the image and the code example is general and
used for virtually all methods, operations and algorithms presented in this topic.