Image Processing Reference
In-Depth Information
This synthetic image can be processed using the Mathcad programming language, which
can be invoked by selecting the appropriate dialog box. This allows for conventional for,
while and if statements, and the earlier assignment operator which is := in non-code
sections is replaced by ← in sections of code. A subroutine that inverts the brightness level
at each point, by subtracting it from the maximum brightness level in the original image,
is illustrated in Code 1.2 . This uses for loops to index the rows and the columns, and then
calculates a new pixel value by subtracting the value at that point from the maximum
obtained by Mathcad's max function. When the whole image has been processed, the new
picture is returned to be assigned to the label newpic . The resulting matrix is shown in
Figure 1.14 (a). When this is viewed as a surface, Figure 1.14 (b), the inverted brightness
levels mean that the square appears dark and its surroundings appear white, as in Figure
1.14 (c).
New_pic:= for x 0..cols(pic)-1
for y 0..rows(pic)-1
newpicture y,x
max(pic)-pic y,x
newpicture
Code 1.2
Processing image points in Mathcad
44
43
42
41 44
44
43
44
43
43
42
43 44
43
43
44
40
30
20
10
0
42
44
7
6
8
9
42
44
41
44
0
1
4
3
43
44
new_pic =
44
43
2
1
5
6
44
42
6
43
44
6
4
3
5
43
44
2
4 6
44
43
44
43 43
42
44
44
44
43
44
42 44
44
41
43
new_pic
(a) Matrix
(b) Surface plot
(c) Image
Figure 1.14
Image of a square after inversion
Routines can be formulated as functions , so they can be invoked to process a chosen
picture, rather than restricted to a specific image. Mathcad functions are conventional, we
simply add two arguments (one is the image to be processed, the other is the brightness to
be added), and use the arguments as local variables, to give the add function illustrated in
Code 1.3 . To add a value, we simply call the function and supply an image and the chosen
brightness level as the arguments.
add_value(inpic,value):= for x 0..cols(inpic)-1
for y 0..rows(inpic)-1
newpicture y,x
inpic y,x +value
newpicture
Code 1.3
Function to add a value to an image in Mathcad
Search WWH ::




Custom Search