LargeImage file viewer
Freeware

"Computers do not solve problems, they execute solutions."    — Laurent Gasser.
On this page:

Intro

This program allows you to quickly view (very) large files in raw binary format as images and save the results as JPG or PNG. This is mostly a reverse engineering tool for simple graphic file formats (namely matrices).

History:
v1.0 — 2002/03/05 — Original release.
v1.1 — 2002/03/13 — Added external palettes; corrected resizing bug; possibility to read 16 bits, 32 bits, float or double values as greyscale.
v1.2 — 2002/03/15 — Added several levels of filter.
v1.4 — 2005/01/20 — Major update: Corrected bug in 16bit auto choice and PNG gamma; added scaling options for 16/32 bit integers and printing option; added OpenGL 3D display; simplified filter menu; added horizontal scale and vertical limits; added position and value display; added horizontal and vertical units; added 3D mapping to an external file...
v1.5 — 2005/02/01 — Added profiles and pointing arrows.
v1.6 — 2005/08/23 — Major update: raised file size limit from 2Gb to 16Eb (should be enough for anybody, right ?); added cartography grids (see mapx documentation); added basic waypoints display.
Bugs/Limitations:
Does not support 16 bits per channel color images.
Sometimes locks up when you double-right-click on the 3D display.


Input file options

I wrote this program so I could quickly view large binary files containing 'visual' information, like a matrix of greyscale bytes or RGB values. This program is complementary of BinToAscii.exe but when the latter is geared towards converting to text values, LargeImage is made for creating images. And it can handle very large files quickly too (a few seconds for a 2Gb files !). Due to my compiler limitations, version 1.0 is currently limited to files smaller than 2Gb.

File InputExplanationScreen output and PNG/JPG output
8 bits greyscaleThis is a standard where one byte represents the greyscale of each pixel (0=black, 255=white).8 bits greyscale
16 bits greyscaleConverted to 8 bits for display and saving.
The values are either divided by 256 or scaled to fit between 0 and 255.
8 bits greyscale
32 bits greyscaleConverted to 8 bits for display and saving.
The values are either divided by 2563 or scaled to fit between 0 and 255.
8 bits greyscale
32 bits floatConverted to 8 bits for display and saving.
The float values are scaled to fit between 0 and 255.
8 bits greyscale
64 bits doubleConverted to 8 bits for display and saving.
The double values are scaled to fit between 0 and 255.
8 bits greyscale
3x8 bits RGBThis is the standard color system, where each color is represented by 24 bits, each byte being alternatively reg, green and blue.3x8 bits color RGB
4x8 bits RGBASame as RGB, but with an extra byte for padding or Alpha Channel.4x8 bits color RGBA or 3x8 bits color RGB

[LI_Prop2.png]
File properties panel of LargeImage.exe

Understanding input file structure

So how does this work ? First you need to have a binary file that you want to represent, but also you need to have an idea of what's in it.

Pixel Structure
Do you know how many bytes per pixel there are and how the bytes are organized (greyscale, color RGB, 32 bits RGB, float, double) ? This is most important and should be set first.
Height & Width
Upon opening a file the properties panel come up and asks you for those values. Do you know how many rows and columns there are ? Here's a formula:

FileSize = Skipped + Width * Height * PixDepth/8

Possible WxH
If you don't know the Height and Width, the program makes suggestions here, based on prime number decomposition so that the area is as close as possible to a square... which might be a far guess if your image is a panorama...
Skip Header bytes
You can also skip some bytes at the beginning of the file.
Skipped Footer bytes
This indicates the number of bytes skipped at the end of the file. Ideally should be 0, and should not be negative (means the program will attempt to read past the end of the file).
Swap bytes
This option will swap the byte order of the file upon reading. Used if reading from a big-endian machine like a Mac or most Unix platforms. If your display looks like a contour plot, it is an indication that you might want to try this option.
Align 32 bits
Is the formula given above accurate ? Not quite. The number of bytes per row can vary with something known as alignment. Sometimes, in order to have each row start on a round word boundary, the number of bytes per row (RowBytes) is rounded off to the nearest higher 32 bit value. This can happen with greyscale images (PixDepth=8) or 24 bits RGB (PixDepth=24). Obviously 32 bits RGB are always aligned on 32 bits boundaries. Well, if you don't know the specific format or if you didn't understand any of this, you can probably ignore this flag on first try. So a more precise formula is:
FileSize = Skipped + RowBytes * Height
RowBytes = (Width * PixDepth/8 + 3) / 4 * 4   if Align32 IS used (using integer arithmetics)
RowBytes = Width * PixDepth/8  if Align32 is NOT used
Scaling
Scale the values fond in the file so that the min value goes to 0 (black) and the max goes to 255 (white). For float and double, scaling is always on, from 16 and 32 bit integer it is optional.
Signed
Interpret the integer values (8, 16 or 32 bits) found in the file as signed values instead of unsigned. If your display looks like a contour plot, it is an indication that you might want to try this option.
Effect
Applies basic symmetries to the image, like mirror, up-down flip or rotate 180 degrees.
Units/Pix and Unit
This is optional. If you know the scale of the image you can indicate it here. For instance '0.125 and km' or the equivalent '125 and m' in the case of the ant125mV2.bin file to indicate that each pixel covers 125 meters. This will add a scale on the view window.
Vertical unit
Optional. For instance if your file represents elevations in meters you could indicate 'm' here.
Arrow
Optional. Draws an arrow pointing to a specific pixel with a specified label. Leave the label blank to avoid drawing an arrow.


Tutorials

Here are 3 example of use of LargeImage which use the Radarsat data. You must first find the files ramp200dem_osu_v2.bin and ant125mV2.bin. If you received this program on a DVD, the files are on it, otherwise go download them from some NASA website. It might take a few weeks if you are on a modem... You need at least version 1.3 of LargeImage to follow this tutorial.


[LI_Thumb.png]
Thumbnail window of LargeImage.exe

Thumbnail window

Open the file ant125mV2.bin and enter the following property values (see Property Box above):

Pixel structure
8 bits greyscale
Possible WxH
48333x41779
Units/pix
0.125
Unit
km
Leave the rest off and click OK.

The program attempts to build a thumbnail view of the file. It does so quickly by accessing only the necessary bytes. A 2Gb file will take only a few seconds to display. Compare this with the time it takes Buy at Amazon.comPhotoShop to ask Windows for enough virtual memory and come back after your coffee... When reading other file types, if the thumbnail is all garbled and does not display what you expect, back to the drawing board, go to the [File][Properties] menu and try again with different parameters.


[LI_View.png]
View Window of LargeImage.exe

The thumbnail has a small red box (left) which represents the View Window (right). The coordinates of this box are shown on the first two lines of the thumbnail panel. Below the 8 arrow buttons allow you to move the View Window by half its size in whichever direction. If you press the [W] button, you get a display of the view window (right). At first the view is at the minimum; try increasing the Reduce factor.


[LI_Options.png]
Advanced options of LargeImage.exe

There are other options you can use from the [File][Options] menu:

Auto-Update
When you change something, will redraw automatically the View window
Stretch threshold and Nb Ignore
When using the 1x1 histogram filter, number of outlying points to drop on each side of the histogram and percentage of outlying points to exclude from the histogram. I wrote this formula years ago and don't remember how it works, but it works pretty well !
Sizes
Allow you to specify the size of the Thumbnail, View and 3D windows. Sometime useful.
Colors
Allow you to set the colors of various user interface items.
Z box 3D
When drawing in 3D mode, the data is drawn inside a box. If the box has horizontal dimensions of 1x1, then this is the relative dimension of the Z axis. Use 100% for a cube. Usually you'll want something flatter.
Pixels on scale
If you indicated units in the file properties window, a scale will be drawn on the view window, with this number of pixels.
Jpg and Png
Various file saving options applying to either JPG or PNG files.

To find out more precisely what each option is, just right-click on it.


[LI_Filter.png]
Same View Window as above after a [Stretch Histogram] filter has been applied

Left: Same View Window as above after a [Stretch Histogram] filter has been applied

View Window

The view window can be a direct extract of the source file or can be manipulated in various ways. First way is to zoom in or out. You can zoom out in two different ways: skipping bytes (a.k.a. decimation) or doing an average of all bytes (a.k.a. resampling). Those two possibilities are accessible from the [Filter] menu. Bear in mind that the resampling option is much slower since it needs to average many bytes each time. The skip method only displays one byte per pixel. Overall, if the data is noisy, it's much better to operate a resampling which will smooth out the small variations. For instance if you zoom out by a factor 4 (example on the right), the resampling will actually average each square of 16 pixels to produce each final pixel. So you should try the resampling option only on your final scan, before saving the file.

When you click on the Thumbnail Window or on the View Window, you center the new View Window on the place you clicked. If you double clicked it will also redraw the view window. Now if you double-right-click the view window, it will re-center, zoom in and redraw. You can also use the numeric keypad to move on the View Window, and [+]/[-] to zoom in/out.

After the skip or resample phase you can optionally apply a 1x1 filter followed by a 3x3 filter (see effect of a [Stretch Histogram] filter on the left). I don't want to go into to much detail here, but there are several pre-programmed filters allowing you to sharpen, smooth, lighten, etc... your image. And if this is not enough, you can define your own custom filters (a very potent possibility).

Other options


[LI_ZoomIn.png]
Zoom into the middle left area after several double-right-click

Right: Zoom into the middle left area after several double-right-click

You can optionally display density histograms for each of the Thumbnail, the View Window before applying the filters (but after the skip/resample) and the View Window after the custom filters have been applied. Click on a filter display to shift between the 3 possible views. Histograms are displayed by density, each color and also the Alpha channel if present. One of the filters, [Stretch Histogram] enlarges the color histogram so as to use all the brightness (in other words, if the original images goes from light grey to dark grey, its contrast is increased so as to go from white to black).


[LI_Hist.png]
Histogram of the View Window before applying the Stretch filter

Left: Histogram of the View Window before applying the Stretch filter. The purple bars show where the histogram will be stretched (left bar becomes black, right bar becomes white).

After the filters have been applied, and if the result is an 8 bit greyscale image, you can optionally apply an external palette to it. The palette must be in the Buy at Amazon.comJASC Paint-Shop-Pro .pal format and can be created with GenPalette.exe.



[LI_Thumb3D.png]
Thumbnail of the ramp200dem_osu_v2.bin file

[LI_Prop.png]
Parameters for the ramp200dem_osu_v2.bin file

3D display

Open the file ramp200dem_osu_v2.bin and enter the following property values (as indicated on the left):

Pixel structure
16 bits greyscale
Possible WxH
28680x24580
Swap bytes
on
Scaling
on
Leave the rest off and click OK.
Go in the [Files][Options] and set the following:
Units/pix
0.200
Unit
km
Vertical unit
m

[LI_View3D.png]
3D view of selected area

Select a view area and display the view window. Then go to [File][3D view] which will display the same area as the view window but in an OpenGL 3D window. The colors are scaled automatically and correspond to black for the minimum value, white for the maximum and in between it follows purple, blue, green, yellow and red. Click and move the mouse to rotate the display; Ctrl-click and move to zoom in and out; shift-click to move the plot around the window. [Right][Click] to open a box that will change many of the parameters (view position, lighting, colors...).


[LI_View3Db.png]
3D view of selected area

File mapping


[LI_MappingProp.png]
File mapping option

Now let's complicate things even further, we'll apply a mapping from an external file. It means the heights on the 3D plot will come from one file while the colors of each pixel will come from another. Select [File][Apply file mapping], select the file ant125mV2.bin and enter the following parameters:

Pixel structure
8 bits greyscale
Possible WxH
48333x41779
Sxx / Syx / Ox
1.6 / 0 / 2440
Sxy / Syy / Oy
0 / 1.6 / -400
Leave the rest off and click OK.

[LI_Mapping.png]
File mapping option

The transformation matrix explains how to go from one pixel on the view to one pixel on the mapping. Here the two files have different scales (200m and 125m) and different reference points (offsets). If you want to map a file of identical size and position, you would just enter 1/0/0 and 0/1/0



[LI_Profile.png]
Simple altitude profile from one side of Antarctica to the other, passing through Dome F, A and C on the way.

Profiles

You can draw simple altitude profile between two points by doing [Alt][left-click] and [Alt][Right-click] on two points of the view window. If you have indicated horizontal and vertical units, they are used to label the axes.

Right: Simple altitude profile from one side of Antarctica to the other, passing through Dome F, A and C on the way.



[LI_GridProp.png]
Properties window for the grid option.

Geographic Grid

The latest addition to the program is the possibility of using advanced mapping functions to draw grid overlays with latitude/longitude lines. This program is turning into a cartography software... The library used is the GPL'd mapx library. You need a Map Projection Parameters (.mpp) file or a Grid Parameter Definition (.gpd) file to explain the correspondence between the X/Y pixel coordinates found in the large file you're viewing and the lat/lon reference found on the real Earth. In the case of the two large Antarctic files I've been using through this tutorial, I've written the two files necessary:

ramp200dem_wgs_v2-polar_stereographic_s00.gpd
Map Projection:                 Polar Stereographic
Map Equatorial Radius:          6378273
Map Reference Latitude:         -90.0
Map Second Reference Latitude:  -71.0
Map Reference Longitude:        0.0
Grid Width:                     28680
Grid Height:                    24580
#Grid Cells Per Map Unit:        500
Grid Map Origin Column:         14345
Grid Map Origin Row:            12280
ant125mV2-polar_stereographic_s00.gpd
Map Projection:                 Polar Stereographic
Map Equatorial Radius:          6378273
Map Reference Latitude:         -90.0
Map Second Reference Latitude:  -71.0
Map Reference Longitude:        0.0
Grid Width:                     48333
Grid Height:                    41779
#Grid Cells Per Map Unit:        500
Grid Map Origin Column:         25392
Grid Map Origin Row:            19248

How does it work ? Do [File][Grid] and click on [Open] to select the appropriate mpp or gpd file. You also need to add the upper and lower X and Y coordinates of the map, which are usually found in a .hdr file provided with mappable files. Here for ant125mV2 the limits are: LX=-3174433, UY=-2406312, RX=2867162, LY=2815937 and for the file ramp200dem_wgs_v2 the limits are: LX=-2868000, UY=-2458000, RX=2868000, LY=2458000


[LI_Waypoints.png]
Global view with grid lines and waypoints.

Other lesser parameters available from the configuration window:

Line interval
Interval in degrees between the various latitude and longitude lines.
Min/Max
Limits within which to draw grid lines
Preferred for labels
Preferred latitude and longitude at which to draw the labels. If out of the screen another value will be determined.
Grid colors
Duh!
Limits
See above.
On/Off
Whether to draw the lines and/or the labels.

Right: Global view with grid lines and waypoints.



[LI_WaypointsTable.png]
Global view with grid lines.

Waypoints

And final option, with the [File][Waypoints] menu you can memorize points. If you are using grids, the waypoints are memorized with their Lat/Lon coordinates and can thus be transfered to other maps; otherwise the X/Y pixel coordinates are used. To memorize a waypoint just [Shift][Ctrl][Alt][Left-click] on the view window. Then enter a name in the Waypoint table. You can read and save to .wpt files which are simple text files. There's not much waypoint edition capabilities within the program but you can simply edit the wpt files manually. If the coords are integer numbers, they are considered X/Y, otherwise they are Lat/Lon.


Summary

So in summary, the image processing happens in the following order:

  1. Read file for thumbnail window
  2. Swap bytes if necessary
  3. If scaling, determines Min/Max value and scale accordingly
  4. Computes thumbnail histogram
  5. Apply optional external palette
  6. Display Thumbnail
  7. Read file for View window
  8. Averages groups of pixels if resampling is used
  9. Computes pre-filter histogram and determines stretch limits
  10. Apply 1x1 filter (contrast, negative, stretch...)
  11. Apply inter-channel filter (BGR -> RGB...)
  12. Apply 3x3 filter (sharpen, edge enhance...)
  13. Apply 5x5 filter (blur more...)
  14. Computes post-filter histogram
  15. Apply optional external palette
  16. Display view window
  17. Display optional overlay data: grid, waypoints, scale, direction arrow...
  18. Display optional 3D OGL view
  19. Apply 3D external file mapping onto 3D display
  20. Back to (6) for next view display

Once you have a good image in your view window, you can save it as JPG or PNG with the menu [File][Save View As]. In short, JPG is good for photography, it is compact but lossy. PNG is bigger but better for archival or paletted images.

What else about this program ? It's freeware and since it's not been extensively tested in some modes, it's probably full of bugs. In particular it's been designed only for large images in mind. I don't know what will happen if you try to display a tiny image in it. You can get more information on most controls by right-clicking them.



Support my site: make a donation, buy images, use associate services
Download: Yes ! Yes ! Yes ! Where is it ? I want to download it now (5Mb) !

Note: The images shown in this example were taken from a 1.9 Gb file of RADARSAT Antarctic data that you can download (warning, 1.6 Gb compressed !) from the UAF's website (Hey, I worked there in '95 !). You can see more of those images on the Antarctic Satellite Images page and the Antarctic Mountains page.

This freeware written with LabWindows/CVI.