メインコンテンツまでスキップ

4.7 画像操作

システムには四つの処理タスクプロセスが用意されている。

(1) Chop。入力画像に、定義されたウィンドウを適用する。

(2) Scale。入力画像を、定義された寸法に拡大または縮小する。

(3) Merge。入力画像を、背景画像の指定された領域に置く。

(4) Clean。入力画像のノイズを除去する。

これらの処理タスクは明快で単純なインタフェースをサポートしているため、コマンド文字列中で使える。ただし、これらのタスクはコマンド文字列中でデータ源にもシンクにもなれない。その入出力のデータ形式はベクタである。

たとえば、ファクシミリのページをクリーニングしてからファクシミリ機に印刷できる。ファクシミリ機へ送る前に、画像データを再圧縮しなければならない点に注意されたい。元のデータが DACOM ブロック形式の場合、処理タスクはラインベクタしか受け付けないため、伸張する必要がある。必要なコマンド文字列を以下に示す。

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

これらの処理タスクの記述は付録 2 にある (chop(fax)、scale(fax)、merge(fax)、clean(fax))。

タスク 'chop' と 'merge' では、頂点の座標を与えることでウィンドウが設定される。しかし、人間のユーザが正確な座標を決めるのは、通常かなり難しい。システムはサブルーチン choice() を提供しており、これは、画像を表示している Grinnell ディスプレイの画面上で矩形部分を対話的に操作することで、画像の矩形部分を指定する。ユーザが関心のある領域を直観的に選べる一連の対話コマンドが用意されている。このサブルーチンは MOS プロセスから呼び出さなければならず、Grinnell ディスプレイがシステムに含まれていなければならない点に注意されたい。

これらの画像処理モジュールにより、2.4 節で述べた画像編集を行える。例を考えてみよう。絵 'a' から切り出した画像を、別の絵 'b' の指定された領域に合成するとする。まず、二つの絵 'a' と 'b' を、それぞれ画面の左半分と右半分に表示しなければならない。二つの絵は、寸法が 1726x1200 の標準的な DACOM ページであるとする。これらは、画面の半分の寸法 (256x512) に合うよう縮小しなければならない。データ形式がベクタでない場合は、先に変換を行う必要があることに注意されたい。必要なコマンド文字列は次のとおりである。

  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

アプリケーションプロセスでは、ユーザが両方の絵の領域を選べるよう、サブルーチン choice() を次のように呼び出す。

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
*/

ユーザが編集を終えると、選択された矩形領域の座標が返される。例を次の表に示す。表に挙げた幅と高さは、返された座標から実際に計算したものであり、元の画像を宛先に合わせて拡大しなければならないことを示している。

         (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

この段階で、以下に示すジョブを実行することで最終目標を達成できる。結果の画像は新しいファイル '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