CHAPTER 7.
MATROX PIP-1024 IMAGE PROCESSOR
1.
FUNCTIONAL DESCRIPTION
Matrox Electronic Systems, Ltd., is a Canadian
company specialized in digital video technology, beginning in the 70's. I remembered that they were the first
company producing Video RAM, which was used by microprocessors to generate text
display to replace CRT terminals, very expensive at the time.
PIP-1024 is one of Matrox's recent product which is a
single board imaging sub-system for IBM PC, XT, and AT computers. It can be
though of as a memory buffer containing a digital representation of an
image. The image has about 1
million pixels arranged in a 1024x1024 matrix. Any portion of a 512x512 pixels subimage
can be displayed on a standard video monitor. Three interfaces exist to the memory
buffer: a PC-bus interface allowing CPU or DMA access; an analog input allowing
an image to be grabbed from a camera; and an analog output allowing the image
to be displayed on a monitor. All
three interfaces can be used at the same time without restriction,
PC accesses the buffer using X-Y coordinate
addressing. Both random and
sequential access are supported, the later using an autoincrement circuitry
which increments the X-Y registers after each access. Using this feature, the DMA unit can be
used to transfer part or all of the image to or from the PC's memory. An optional interrupt is supplied on
completion of the DMA transfer, allowing the CPU to continue with other work while
the transfer is taking place.
PIP-1024 digitizes images in real time, 30 frames per
second, from the frame grab input port.
It accepts RS-170 composite video signals from an external video source,
such as a camera, a video recorder, or another PIP-1024. The digitizer runs at 10 Mhz with 8 bit
accuracy. A write-protect mask can
be used to selectively prevent overwriting of any of the 8 bit memory
planes. Protected planes can be
used to store graphics, characters, or cursors.
The image is displayed by converting the digital
intensity value for each pixel back into analog video signal. The 8 bit pixel intensity is passed
through a color look-up table which maps the 256 possible intensity values to
256 colors or shades of grey. The
256 displayable colors are selectable from a 16.7 million color palette. A keying circuit allows the user to
overlay the contents of the frame buffer with the incoming signal.
2.
THE PROGRAMMING MODEL
PIP-1024 talks to the PC host through a group of I/O
ports on the PC-bus. The locations
and functions of these ports are summarized in Figure 13. The absolute port addresses can be
changed by a jumper on the PIP-1024 board.
Figure
13. PIP-1024 Register Addresses and
Functions
Register
Offset Read Register Write
Register
026C Status
Control 0
066C
Snapshot Control 1
0A6C
Clear
interrupt Control 2
0E6C
Control
mask data
126C
CRTC
status CRTC address
166C
CRTC data CRTC data
1A6C
Video
gain
1E6C
Video
set up
226C
Input
LUT data
266C
Output
blue LUT data
2A6C
Output
green LUT data
2E6C
Output
red LUT data
326C
X
pixel address
366C
Y
pixel address
3A6C
Pixel
data Pixel data
02F4(absolute)
Interrupt enable
It is not appropriate to discuss the bits and fields
in all these registers in great details here. One would have to refer to the PIP
manual for detailed information. To
control the image processor board, the control registers 0 and 1 are used to
select functions like enabling the look-up tables (LUT), enable DMA read or
write, selecting input channel, internal or external sync, input keying,
enabling continuous frame grabbing or snapshot, etc.
The PIP board uses a Synertek SY6845E CRT controller
chip to generate all the video timing signals and to control the image buffer
memory. This CRTC chip is a very
complicated device, having 22 internal registers for its configuration and
operation. It is accessible by the PC host through two PC I/O ports at 126C and
166C. This is the same video chip
used in IBM PC for color and monochrome displays. Normally the PIP user does not have to
touch this chip, as it is automatically configured by PIP board.
PIP is booted into the monochrome mode, in which the
look-up tables for the red, green, and blue channels are initialized to a unity
function. To display pseudo colors,
one will have to rewrite the look-up tables to specify the desired color
transformation. This is done by
writing into the proper LUT through the corresponding LUT data register. The byte address in the LUT is selected
by writing to the X-pixel register.
To read or write directly from/to the image buffer,
the X and Y coordinate of the desired pixel must be written into the X- and
Y-pixel address registers, and then the pixel data can be read or written
through the pixel data register.
Part of the Control 2 register must be used because it takes 20 bits of
address to locate a pixel in a 1024x1024 pixel array. Consecutive bytes in the
image buffer can be accessed when the Counter-Enable bit in Control 0 register
is set. This is convenient to
upload an image from PC to PIP or download an image from PIP to PC. Two other bits in Control 0 register
control the direction and transferring of data to/from the PC in the DMA mode.
3.
PROGRAMMING PIP-1024
Matrox supplies very extensive software for
PIP-1024. It includes an
interactive control program PIPINT, and several libraries to be linked with
FORTRAN or C programs. When PIPINT
is loaded into PC, the user can type in many image processing commands to do
many things like acquiring images, enhancing the images, upload/down load
images, etc. These interactively
executable functions are also in the libraries, readily callable from FORTRAN
or C programs. Novice users and
sophisticated users can all make this board to do useful work in a relatively
short time. Matrox did a very good
job in supporting the hardware.
In spite of the good software tools supplied by
Matrox, I still feel being put in a straight-jacket in using PIPINT. If what you wanted to do is what was
programmed in PIPINT, it does a good job.
But you always want to do something more sophisticated, or just plainly
different. Forth gives you the
freedom of tailoring the system to your own needs. The program in Listing 9 is my way of
using PIP-1024 through Forth, which is more elegant, I think, than PIPINT,
because it can be customized to any application.
When I started to use PIP-1024, I tried to exercise
several bits in the control registers which produced visible results on the CRT
monitor, to make sure that I had the full control over the system. Several of these functions are shown in
Screen 1 of Listing 9. SNAP takes a
snap shot and shows an image grabbed from a video camera on the monitor. After I got an image in the image buffer
memory, I could then enhance the image by changing the brightness and contrast
of the display using the commands GAIN and OFFSET. MASK disabled some bits in the frame
grabbing process and produced very interesting effect when two images were
superposed in different memory planes.
CTRL0, CTRL1, and CTRL2 are commands to deposit byte
patterns into the control registers.
They form the basis to build other more powerful image processing
commands. They are used to define
the functions in Screen 2.
VREAD and VWRITE in Screen 3 are basic words to copy
image data between the PIP image buffer and PC memory. They invoke the command VRAM to set up
PIP for autoincrement memory access, so that every time PIP memory is accessed,
the X,Y address registers are incremented, making the next byte in image buffer
accessible in the next memory cycle.
In one of our applications, we wanted to transfer
subimages of 128x128 pixels between PIP and the disk on PC. It required that a subimage anywhere in
the image buffer could be accessed. (LINE) in Screen Screen 4 initializes the
address registers to access one line of image data at the x,y coordinates. ROWR reads 128 bytes from image buffer
to PC and ROWW writes 128 bytes from PC to image buffer. STORE-IMAGE picks a subimage at (x,y)
and stores it in the currently opened file. FETCH-IMAGE gets the data from the
current file to a subimage in PIP.
Pseudo color is always fun. Any grey scale image can be made more interesting
by coloring different parts with different colors. The commands RED, GREEN, and BLUE write
LUT look-up tables to the corresponding channels, assuming that the address of
a 256 byte table is on the stack.
COLOR-MAP creates a triangle function in the buffer SCRATCH. By fetching different regions in the
SCRATCH buffer into the red, green, and blue LUT's, we can create interesting
pseudo color schemes. One of such
scheme is realized in the command PSEUDO-COLOR in Screen 7, which produces a
color sequence of black-red-green-blue-black with increasing pixel values. NORMAL displays a normal black/ white
image. REVERSE turns black to white
and white to black.
ENHANCE is an interesting way to enhance a
black/white image. It takes two parameters on the stack: a contrast value and a
brightness value. It produces a
look-up table with an S- shaped intensity transformation curves: the center of
the sloped portion of the curve is specified by brightness value and the slope
of this portion by the contrast value.
Figure 14 shows the intensity transformation curves produced by the
commands
1 128 ENHANCE and 3 75 ENHANCE
The latter command enhances the pixel values between
75-42 and 75+42, the pixels with values from 0 to 42 are displayed in black,
and those between 117 and 255 are displayed in white. ENHANCE is very effective
in sharpening a poor image in which pixel values are compressed into a narrow
band, such as an image taken by a camera with insufficient lighting.
Figure 14.
Intensity Transformation Curves.
. .
. . .
. . .
. .
. . .
. . .
. . .
.
.
+
.
+++++++++++++
.
+ .
.
+
.
.
+ .
.
+
.
Output.
+ . Output.
+
.
Value .
+
. Value .
+
.
.
+
. .
+
.
.
+
.
.
+
.
. +
.
.
+
.
. +
.
.
+
.
+ . .
. . .
. . .
.
+++++++ . .
. . .
. .
Input Value
Input Value
1 128 ENHANCE
3 75 ENHANCE
Listing 9.
Matrox PIP-1024 utility
Figure 15.
Matrox PIP-512 brochure