home *** CD-ROM | disk | FTP | other *** search
- unit User;
-
- {This module is a good place to put user additions to Image. You will need }
- {to uncomment the call to InitUser in Image.p.}
-
-
- interface
-
- uses
- QuickDraw, Palettes, PrintTraps, globals, Utilities, Graphics;
-
-
- procedure InitUser;
- procedure DoUserCommand1;
- procedure DoUserCommand2;
- procedure DoUserMenuEvent (MenuItem: integer);
-
-
- implementation
-
- {User global variables go here.}
- var
- color: integer;
-
-
- procedure InitUser;
- begin
- UserMenuH := GetMenu(UserMenu);
- InsertMenu(UserMenuH, 0);
- DrawMenuBar;
- {Additional user initialization code goes here.}
- end;
-
-
- procedure DrawDot (row, column, RowOffset, ColumnOffset: integer; big: boolean);
- var
- h, v: integer;
- begin
- if big then begin
- for h := -1 to 1 do
- for v := -1 to 1 do
- PutPixel(column * 16 + ColumnOffset * 4 + h + 16, row * 16 + RowOffset * 4 + v + 16, color)
- end
- else
- PutPixel(column * 16 + ColumnOffset * 4 + 16, row * 16 + RowOffset * 4 + 16, color);
- end;
-
- procedure DrawNeighborhood (i, row, column: integer);
-
- begin
- DrawDot(row, column, 0, 0, BitAnd(i, 1) = 1);
- DrawDot(row, column, 0, 1, BitAnd(i, 2) = 2);
- DrawDot(row, column, 0, 2, BitAnd(i, 4) = 4);
- DrawDot(row, column, 1, 2, BitAnd(i, 8) = 8);
- DrawDot(row, column, 2, 2, BitAnd(i, 16) = 16);
- DrawDot(row, column, 2, 1, BitAnd(i, 32) = 32);
- DrawDot(row, column, 2, 0, BitAnd(i, 64) = 64);
- DrawDot(row, column, 1, 0, BitAnd(i, 128) = 128);
- DrawDot(row, column, 1, 1, true);
- end;
-
-
- procedure SetColor (i: integer);
- {Color neighborhoods to show which ones would be removed on the first pass(150), second pass(100),}
- {or either pass(200) when using the Zhang and Suen thinning algorithm(CACM, Mar. 1984,236-239).}
- var
- p2, p3, p4, p5, p6, p7, p8, p9, A, B: integer;
- begin
- p2 := bsr(band(i, 2), 1);
- p3 := bsr(band(i, 4), 2);
- p4 := bsr(band(i, 8), 3);
- p5 := bsr(band(i, 16), 4);
- p6 := bsr(band(i, 32), 5);
- p7 := bsr(band(i, 64), 6);
- p8 := bsr(band(i, 128), 7);
- p9 := band(i, 1);
- A := 0;
- if (p2 = 0) and (p3 = 1) then
- A := A + 1;
- if (p3 = 0) and (p4 = 1) then
- A := A + 1;
- if (p4 = 0) and (p5 = 1) then
- A := A + 1;
- if (p5 = 0) and (p6 = 1) then
- A := A + 1;
- if (p6 = 0) and (p7 = 1) then
- A := A + 1;
- if (p7 = 0) and (p8 = 1) then
- A := A + 1;
- if (p8 = 0) and (p9 = 1) then
- A := A + 1;
- if (p9 = 0) and (p2 = 1) then
- A := A + 1;
- B := p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
- color := 255;
- if A = 1 then
- if (B >= 2) and (B <= 6) then begin
- if ((p2 * p4 * p6 = 0) and (p4 * p6 * p8 = 0)) and ((p2 * p4 * p8 = 0) and (p2 * p6 * p8 = 0)) then
- color := 200
- else if (p2 * p4 * p6 = 0) and (p4 * p6 * p8 = 0) then
- color := 150
- else if (p2 * p4 * p8 = 0) and (p2 * p6 * p8 = 0) then
- color := 100;
- end;
- end;
-
-
- procedure DoUserCommand1;
- {Generates a table showing all possible 3x3 neighborhoods. This table is used}
- { for making up the "fate table" used by the Skeletonize command and the Wand tool.}
- var
- row, column, index: integer;
- begin
- row := 0;
- column := 0;
- if NewPicWindow('Fate Table', 600, 200) then
- for index := 0 to 255 do begin
- SetColor(index);
- DrawNeighborhood(index, row, column);
- column := column + 1;
- if column = 32 then begin
- row := row + 1;
- column := 0;
- end;
- end;
- end;
-
-
- procedure DoUserCommand2;
- begin
- beep;
- end;
-
- procedure DoUserMenuEvent (MenuItem: integer);
- begin
- case MenuItem of
- 1:
- DoUserCommand1;
- 2:
- DoUserCommand1;
- end;
- end;
-
- end.