Image Viewer Algorithm

Theory

The main motive for development of a cluster-based image viewer is to display high-resolution large-scale images containing millions of pixels. These images cannot be viewed on a single workstation PC without loss of details or loss of context. Tiled display image viewer offers a cheaper alternative when compared to high-definition display systems developed for this purpose.

Algorithm

Step 1
Initialize MPI.
RANK = rank of the node in the cluster.

Initialize SDL.
VIDEO_WIDTH = maximum resolution width of the display.
VIDEO_HEIGHT = the maximum resolution height of the display.
Set the video mode to VIDEO_WIDTH x VIDEO_HEIGHT

Step 2
If RANK = 0 (Server Node)
Initialize the Agar GUI subsystem.
Display the GUI on the server node.

Step 3
Displaying Image -
Open the image file and read the following image file information -
Depth (in bits/pixel).
Width (in pixels) - IMAGE->W.
Height (in pixels) – IMAGE->H.

Offset (in pixels) – Thickness of the display monitor boundary.

Calculate the coordinates for the image divisions based on the rank.
If RANK = 1
X = 0 W = (VIDEO_WIDTH)+Offset
Y = 0 H = (VIDEO_HEIGHT)+Offset

If RANK = 2
X = (VIDEO_WIDTH)+(2*Offset)
Y = 0
W = (VIDEO_WIDTH)
H = (VIDEO_HEIGHT)+Offset

If RANK = 3
X = (VIDEO_WIDTH)+(2*Offset)
Y = (VIDEO_HEIGHT)+(2*Offset)
W = (VIDEO_WIDTH)+Offset
H = (VIDEO_HEIGHT)

If RANK = 4
X = 0
Y = (VIDEO_HEIGHT)+(2*Offset)
W = (VIDEO_WIDTH)
H = (VIDEO_HEIGHT)

Step 4
Zoom in / Zoom out image to maintain the aspect ratio

IMG_AR = IMAGE->W / IMAGE-> H
SCRN_AR = VIDEO_WIDTH / VIDEO_HEIGHT

If (IMAGE->W - VIDEO_WIDTH) > (IMAGE->H – VIDEO_HEIGHT)
xfactor = IMAGE->H / (VIDEO_HEIGHT)
yfactor = xfactor

Else
yfactor = IMAGE->W / (VIDEO_WIDTH)
xfactor = yfactor

Zoom image with factor xfactor & yfactor.

Step 5
Synchronization of tile nodes.

Wait for blit signal from the server.
If (signal is received)
Blit image on the screen surface.

Wait for keyboard events.

Step 6
Finalize SDL
Finalize MPI
Exit.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.