Program © 1998-2013 Guillaume Dargaud. Free use and distribution.
Last updated on 2012/12/13
"Computers do not solve problems, they execute solutions." — Laurent Gasser.
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).
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 Input||Explanation||Screen output and PNG/JPG output|
|8 bits greyscale||This is a standard where one byte represents the greyscale of each pixel (0=black, 255=white).||8 bits greyscale|
|16 bits greyscale||Converted 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 greyscale||Converted 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 float||Converted to 8 bits for display and saving.|
The float values are scaled to fit between 0 and 255.
|8 bits greyscale|
|64 bits double||Converted to 8 bits for display and saving.|
The double values are scaled to fit between 0 and 255.
|8 bits greyscale|
|3x8 bits RGB||This 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 RGBA||Same as RGB, but with an extra byte for padding or Alpha Channel.||4x8 bits color RGBA or 3x8 bits color RGB|
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.
FileSize = Skipped + Width * Height * PixDepth/8
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.
Open the file ant125mV2.bin and enter the following property values (see Property Box above):
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 PhotoShop 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.
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.
There are other options you can use from the [File][Options] menu:
To find out more precisely what each option is, just right-click on it.
Left: Same View Window as above after a [Stretch Histogram] filter has been applied
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).
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).
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 JASC Paint-Shop-Pro .pal format and can be created with GenPalette.exe.
Open the file ramp200dem_osu_v2.bin and enter the following property values (as indicated on the left):
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...).
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:
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
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.
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:
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
Other lesser parameters available from the configuration window:
Right: Global view with grid lines and 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.
So in summary, the image processing happens in the following order:
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.
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.