Difference between revisions of "Mipmap Generator 2D Manual"
From Immersive Visualization Lab Wiki
m (→1. Mipmaps) |
m (→Readers) |
||
(21 intermediate revisions by one user not shown) | |||
Line 2: | Line 2: | ||
===Synopsis=== | ===Synopsis=== | ||
+ | ---- | ||
:./MipmapGen2D [-f <u>format</u> -s <u>brickSize</u>] <u>imageFilename</u> <u>maxLevel</u> | :./MipmapGen2D [-f <u>format</u> -s <u>brickSize</u>] <u>imageFilename</u> <u>maxLevel</u> | ||
− | :./MipmapGen2D [-f <u>format</u> -s <u>brickSize</u>] <u>inputBatchFilename</u> <u>maxLevel</u> [<u>outputBatchFilename</u>] | + | :./MipmapGen2D [-f <u>format</u> -s <u>brickSize</u>] <u>inputBatchFilename</u> <u>maxLevel</u> [<u>outputBatchFilename</u>] |
===Description=== | ===Description=== | ||
+ | ---- | ||
:'''1. Generate mipmaps for an image:''' | :'''1. Generate mipmaps for an image:''' | ||
::Generate mipmaps for an image specified by <u>imageFilename</u>, from level 0 (the original image size) to the level specified by <u>maxLevel</u>. If the <u>maxLevel</u> is -1, MipmapGen2D generates all the mipmaps from the original image size to the biggest size smaller than the <u>brickSize</u>. | ::Generate mipmaps for an image specified by <u>imageFilename</u>, from level 0 (the original image size) to the level specified by <u>maxLevel</u>. If the <u>maxLevel</u> is -1, MipmapGen2D generates all the mipmaps from the original image size to the biggest size smaller than the <u>brickSize</u>. | ||
:'''2. Generate mipmaps for a set of images:''' | :'''2. Generate mipmaps for a set of images:''' | ||
− | ::Generate mipmaps for a set of images listed in the inputBatchFilename</u>, all from level 0 (the original image size) to the level specified by maxLevel</u>. | + | ::Generate mipmaps for a set of images listed in the <u>inputBatchFilename</u>, all from level 0 (the original image size) to the level specified by <u>maxLevel</u>. |
::If <u>outputBatchFilename</u> is specified, MipmapGen2D assumes the image set is an animation, and generates a single text file which lists mipmaps for each frame and timestamps. If <u>outputBatchFilename</u> is not specified, it’s the same as a batch mipmaps generation. MipmapGen2D generates mipmaps and a text file for each image in the set, as if they are generated separately. | ::If <u>outputBatchFilename</u> is specified, MipmapGen2D assumes the image set is an animation, and generates a single text file which lists mipmaps for each frame and timestamps. If <u>outputBatchFilename</u> is not specified, it’s the same as a batch mipmaps generation. MipmapGen2D generates mipmaps and a text file for each image in the set, as if they are generated separately. | ||
===Options=== | ===Options=== | ||
+ | ---- | ||
:'''-f <u>format</u>''' | :'''-f <u>format</u>''' | ||
::Specify file format for the output mipmaps. Default is mix. | ::Specify file format for the output mipmaps. Default is mix. | ||
− | ::'''sep''' Save all pixels of a channel together, i.e. RRR…R, GGG…G, BBB…B | + | ::'''sep''' |
− | ::'''mix''' Save channels of one pixel together, i.e. RGB, RGB, RGB…RGB | + | :::Save all pixels of a channel together, i.e. RRR…R, GGG…G, BBB…B |
+ | ::'''mix''' | ||
+ | :::Save channels of one pixel together, i.e. RGB, RGB, RGB…RGB | ||
:'''-s <u>brickSize</u>''' | :'''-s <u>brickSize</u>''' | ||
::Specify the brick size. Default is 128. | ::Specify the brick size. Default is 128. | ||
− | |||
− | |||
− | |||
===File format=== | ===File format=== | ||
− | ==== | + | ---- |
+ | ====Mipmaps==== | ||
:For each mipmap level of an image, we divide the output mipmap into fixed size bricks (Fig. 1), and save all the bricks of one mipmap level to one file. | :For each mipmap level of an image, we divide the output mipmap into fixed size bricks (Fig. 1), and save all the bricks of one mipmap level to one file. | ||
Line 32: | Line 35: | ||
:<div style="text-align: center;">Fig. 1</div> | :<div style="text-align: center;">Fig. 1</div> | ||
− | : | + | :For each output mipmap, we put all the pixels of one brick together and save those bricks one by one continuously (Fig. 2). The output mipmaps are not human readable. However, if the TIFF format is used, one can view bricks by TIFF’s sub-image. |
:[[Image:MipmapGen2D fig2.jpg|300px|center]] | :[[Image:MipmapGen2D fig2.jpg|300px|center]] | ||
:<div style="text-align: center;">Fig. 2</div> | :<div style="text-align: center;">Fig. 2</div> | ||
− | ==== | + | :The filenames for the mipmaps will follow the format: |
+ | ::'''filename_of_the_input_image.mipmap_level.filename_extension''' | ||
+ | |||
+ | ====Text Files==== | ||
:'''1. Output text file''' | :'''1. Output text file''' | ||
::The output text file for a single input image contents the image definition, and file paths for all the mipmaps. | ::The output text file for a single input image contents the image definition, and file paths for all the mipmaps. | ||
Line 52: | Line 58: | ||
5 /filePath/example.4.tif 128 64 | 5 /filePath/example.4.tif 128 64 | ||
− | :'''2. Input batch file | + | :'''2. Input batch file <u>inputBatchFilename</u>''' |
::The input batch file starts with the number of images in the file, and then lists the file names for each image. | ::The input batch file starts with the number of images in the file, and then lists the file names for each image. | ||
Line 64: | Line 70: | ||
/filePath/example3.tif | /filePath/example3.tif | ||
− | :'''3. Output batch file | + | :'''3. Output batch file <u>outputBatchFilename</u>''' |
::The input batch file first specifies number of images listed in the file, and then lists all the file names for all the mipmaps of each image. | ::The input batch file first specifies number of images listed in the file, and then lists all the file names for all the mipmaps of each image. | ||
::Sample file: | ::Sample file: | ||
− | <font color="blue"># Number of images</font> | + | <font color="blue">'''# Number of images'''</font> |
3 | 3 | ||
Line 89: | Line 95: | ||
===Readers=== | ===Readers=== | ||
− | :'''int getOneChannelData(int <u>x</u>, int <u>y</u>, int <u>c</u>, unsigned char *<u>buf</u>);''' | + | ---- |
− | ::Get all the pixels in c-th channel of brick (x, y), and put it in the buf | + | :There are two C functions to access bricks in the mipmaps: |
+ | |||
+ | ::'''int getOneChannelData(int <u>x</u>, int <u>y</u>, int <u>c</u>, unsigned char *<u>buf</u>);''' | ||
+ | :::Get all the pixels in c-th channel of brick (x, y), and put it in the buf | ||
+ | |||
+ | ::'''int getMultiChannelData(int <u>x</u>, int <u>y</u>, unsigned char *<u>buf</u>);''' | ||
+ | :::Get all the pixels in all channel of brick (x, y), and put it in the buf | ||
+ | |||
+ | :Readers access a brick with it’s coordinate (x, y) (Fig. 1), which starts from the lower left corner of the image, and put it in a 1D array. | ||
+ | |||
+ | :Note that we don’t pad for the boundary bricks smaller than the brick size. So the user should be aware of the size change on the boundaries and allocate the <u>buf</u> appropriately. | ||
+ | |||
+ | ===Version=== | ||
+ | ---- | ||
+ | :Current version only supports TIFF image. The input TIFF image should be uncompressed. Only the data chunk specified by the first image file directory (IFD) will be processed. | ||
− | + | ===Downloads=== | |
− | + | ---- | |
− | : | + | [http://www.cse.ucsd.edu/~kuhsu/mipmapGen/downSampler2D.tar.gz downsampler 2D] |
− | : | + | [http://www.cse.ucsd.edu/~kuhsu/mipmapGen/reader2D.tar.gz reader 2D] |
Latest revision as of 18:49, 8 April 2008
Generate mipmaps for 2D images.
Contents |
Synopsis
- ./MipmapGen2D [-f format -s brickSize] imageFilename maxLevel
- ./MipmapGen2D [-f format -s brickSize] inputBatchFilename maxLevel [outputBatchFilename]
Description
- 1. Generate mipmaps for an image:
- Generate mipmaps for an image specified by imageFilename, from level 0 (the original image size) to the level specified by maxLevel. If the maxLevel is -1, MipmapGen2D generates all the mipmaps from the original image size to the biggest size smaller than the brickSize.
- 2. Generate mipmaps for a set of images:
- Generate mipmaps for a set of images listed in the inputBatchFilename, all from level 0 (the original image size) to the level specified by maxLevel.
- If outputBatchFilename is specified, MipmapGen2D assumes the image set is an animation, and generates a single text file which lists mipmaps for each frame and timestamps. If outputBatchFilename is not specified, it’s the same as a batch mipmaps generation. MipmapGen2D generates mipmaps and a text file for each image in the set, as if they are generated separately.
Options
- -f format
- Specify file format for the output mipmaps. Default is mix.
- sep
- Save all pixels of a channel together, i.e. RRR…R, GGG…G, BBB…B
- mix
- Save channels of one pixel together, i.e. RGB, RGB, RGB…RGB
- -s brickSize
- Specify the brick size. Default is 128.
File format
Mipmaps
- For each mipmap level of an image, we divide the output mipmap into fixed size bricks (Fig. 1), and save all the bricks of one mipmap level to one file.
- Fig. 1
- For each output mipmap, we put all the pixels of one brick together and save those bricks one by one continuously (Fig. 2). The output mipmaps are not human readable. However, if the TIFF format is used, one can view bricks by TIFF’s sub-image.
- Fig. 2
- The filenames for the mipmaps will follow the format:
- filename_of_the_input_image.mipmap_level.filename_extension
Text Files
- 1. Output text file
- The output text file for a single input image contents the image definition, and file paths for all the mipmaps.
- Sample file (a line starts with ‘#’ is a comment line):
# Image../data/example.tif # Image definition (image number, brick size, maximum mipmap level, # channels) 0 128 5 3 #mipmap level 0 definition (mipmap level, file name, size in X, size in Y 0 /filePath/example.0.tif 2048 1024 1 /filePath/example.1.tif 1024 512 …… 5 /filePath/example.4.tif 128 64
- 2. Input batch file inputBatchFilename
- The input batch file starts with the number of images in the file, and then lists the file names for each image.
- Sample file:
# number of images 3 # images /filePath/example1.tif /filePath/example2.tif /filePath/example3.tif
- 3. Output batch file outputBatchFilename
- The input batch file first specifies number of images listed in the file, and then lists all the file names for all the mipmaps of each image.
- Sample file:
# Number of images 3 # Image data/example1.tif # Image definition (image number, brick size, maximum mipmap level, # channels 1 128 4 3 # mipmap level 0 definition (mipmap level, file name, size in X, size in Y 0 /filePath/example1.0.tif 1024 1024 …… 4 /filePath/example1.3.tif 128 128 # Image data/example2.tif # Image definition (image number, brick size, maximum mipmap level, # channels 2 128 5 3 # mipmap level 0 definition (mipmap level, file name, size in X, size in Y …… # Image data/example3.tif ……
Readers
- There are two C functions to access bricks in the mipmaps:
- int getOneChannelData(int x, int y, int c, unsigned char *buf);
- Get all the pixels in c-th channel of brick (x, y), and put it in the buf
- int getOneChannelData(int x, int y, int c, unsigned char *buf);
- int getMultiChannelData(int x, int y, unsigned char *buf);
- Get all the pixels in all channel of brick (x, y), and put it in the buf
- int getMultiChannelData(int x, int y, unsigned char *buf);
- Readers access a brick with it’s coordinate (x, y) (Fig. 1), which starts from the lower left corner of the image, and put it in a 1D array.
- Note that we don’t pad for the boundary bricks smaller than the brick size. So the user should be aware of the size change on the boundaries and allocate the buf appropriately.
Version
- Current version only supports TIFF image. The input TIFF image should be uncompressed. Only the data chunk specified by the first image file directory (IFD) will be processed.