A ground point (or an object point) may be captured or presented in multiple images in an image sequence if those images are overlapped. The figure below illustrates a ground point exists on multiple images.
For some situations, we need to know in which images a ground point exists. Aerial triangulation (AT) algorithm, for example, involves a large number of tiepoints, ground points, and EOs of all images in the sequence. Below is a picture of a file containing a list of tiepoints - saying on which image ID, an object point (mentioned by ID) shows up and at which (x,y) coordinate. The file contains the whole image points in the sequence. The structure of each point composes of ‘Image ID’, ‘Object ID’, ‘Image point (x,y)’. The ‘Object ID’ of one image is usually duplicated along the adjacent images as its corresponding tiepoints (or image point) shares the same ground point.
To record that which object ID is in which image ID, we can simply use a vector of std::set.
Object ID: 1 --> Image ID: {1, 2, 3, 4}
Object ID: 2 --> Image ID: {1, 2, 3, 4, 5}
Object ID: 3 --> Image ID: {2, 3, 4, 5}
But, that consumes a huge memory as long as the sets and the number of object ID go bigger. In my work (particularly, image matching), I have created CBits class that uses each bit in DWORD to represent each image ID. Thus, instead of having a vector of std::set, we use a vector of CBits to store the relationship between Object ID and a list of image ID. This is presented as the image below:
If the object point exists in an image, the bit value of that image index is marked as 1. Otherwise, it is marked as 0. The structure of DWORD_BITS is simply 4 DWORDs, in which each DWORD defines different range of bits.
The CBits class is laid out as the figure below. Its function is to handle bit-wise operations on the defined DWORD_BITS struct.
Its functions are:
bool IsBitSet(DWORD dword_bits, int x)
This function checks if the specified bit (x) in the passed-in dword_bits is set to 1 or not. The checking is done by employing the std::bitset class as follows:
typedef bitset<32> BITS32;
return BITS32(dword_bits).test(x);
void SetBit(DWORD_BITS &dword_bits, int x)
This function is to set the specified bit (x) to 1. The detailed description of the function is presented as follows:
1. Check if the bit to set, x, is greater than the limitation or not (128 in this case). If so, the program exists.
2. Since the structure of image bits is defined to 4 DWORD: dword0, dword1, dword2 and dword3, the program check if which index of DWORD is set and at which bit.
a. Get the index of DWORD either 0, 1, 2 or 3.
index_dword = x/32
b. Get the index of bits either 0, 1, 2,…, 31.
index_bit = x%32
3. Set the specified bit to 1 by using the bit-shift operator.
int GetNextBitSet(DWORD_BITS const &dword_bits, int iStart, int iStop)
This function finds the bit index that is set to 1 starting from the iStart index until the iStop index.
Sourcecode:
Bits.h // Declaration for the CBits class
Bits.cpp // Implementation for the CBits class
Definition.h // Structure and constant declaration
Download: [Zip] [GitHub]
No comments:
Post a Comment