4.7 Image Manipulation
Four processing task processes are provided in the system. These are:
(1) Chop, which applies a defined window to the input image.
(2) Scale, which enlarges or shrinks the input image to the defined dimensions.
(3) Merge, which puts the input image on the specified area of a background image.
(4) Clean, which removes the noise on the input image.
The Clean and Simple interfaces are supported in these processing tasks so that the tasks can be used in command strings. However, these tasks can be neither source nor sink in a command string. The data format of their input and output is vector.
For example, a facsimile page can be cleaned and then printed on the facsimile machine. Note that the image data must be recompressed before being sent to the facsimile machine. If the original data is the form of DACOM block, it has to be decompressed as the processing tasks only accept line vectors. The required command string is shown below.
fs"e,page|clean|recomp|fax"w
where fs - file system task
e - read an existing file
page - file name
clean - cleaning task
recomp - re-compression task
fax - interface task for facsimile machine
w - print an image on facsimile machine
The descriptions of these processing tasks can be found in Appendix 2 (chop(fax), scale(fax), merge(fax), and clean(fax)).
In tasks 'chop' and 'merge', a window is set by giving the coordinates of its vertices. However, it is usually rather difficult for a human user to decide the exact coordinates. The system supplies a subroutine choice() which specifies a rectangular subsection of an image by interactive manipulations of a rectangular subsection on the screen of the Grinnell display displaying the image. It provides a set of interactive commands whereby a user can intuitively choose an area he is interested in. Note that this subroutine must be called by a MOS process and the Grinnell display must be included in the system.
By means of these image processing modules, the image editing described in section 2.4 can be carried out. Let us consider an example. An image abstracted from a picture 'a' is to be merged onto a specified area of another picture 'b'. First of all, the two pictures 'a' and 'b' should be displayed on the left half and right half of the screen, respectively. Assume that the two pictures are standard DACOM pages whose dimensions are 1726x1200. They have to be shrunk to fit the dimension of the half screen (256x512). Note that if the data format is not vector, conversion should be carried out first. the required command strings are:
e,a|scale"1726,1200,256,512|grinnell"0,511,255,0,z,g
fs"e,b|scale"1726,1200,256,512|grinnell"256,511,511,0,z,b
where fs - file system task
e - read an existing file
a - file name
b - file name
scale - scale task
1726,1200 - old dimension
256,512 - new dimension
grinnell - grinnell display interface task
0,511,255,0 - presentation area (the left half)
256,511,511,0 - presentation area (the right half)
z - zero write mode
g - green
b - blue
In an application process, the subroutine choice() is called in the following ways for the user to choose the areas on both pictures.
choice(r, 1726, 1200, 1, 0, 0);
/* choice the area on 'a' */
/* r - red
1726 - width of the original picture
1200 - height of the original picture
1 - left half of the screen
0 - the subsection can be of any width
0 - the subsection can be of any height
*/
choice(r, 1726, 1200, 2, 0, 0);
/* choice the area on 'b' */
/* r - red
1726 - width of the original picture
1200 - height of the original picture
2 - right half of the screen
0 - the subsection can be of any width
0 - the subsection can be of any height
*/
When the user finishes editing, the coordinates of the chosen rectangular areas are returned. An example is given in the table below. The widths and heights listed in the table are actually calculated from the coordinates returned and they indicate that the source image has to be enlarged to fit its destination.
(0, 0)
+-------------------------------> x
|
| (x0, y0) w
| +--------------------+
| ! !
| ! !
| ! ! h
| ! !
| ! !
| +--------------------+
| (x1, y1)
V
y
original x0 y0 x1 y1 w h
a 30 40 100 120 70 80
b 100 100 1100 1100 1000 1000
At this stage, our final goal can be achieved by performing a job specified below. It is assumed that the result image is to be stored as a new file 'c'.
fs"e,a|chop"30,40,100,120|scale"70,80,1000,1000
|merge"b,0,100,100,1100,1100|fs"c,c
where fs - file system task
e - read an existing file
a - file name
chop - chop task
30,40,100,120 - the area to be abstracted
scale - scale task
70,80 - old dimension
1000,1000 - new dimension
merge - merge task
b - file name of the background image
0 - to be overlaid
100,100,1100,1100 - the area to be overlaid
fs - file system task
c - create a new file
c - the name of the file to be
created