public static void Update(IBitWord bw, UInt32[] bytes4) { ((BitWord_8)bw).Byte1to4 = bytes4[0]; ((BitWord_8)bw).Byte5to8 = bytes4[1]; }
public override void Init() { HammingLookup.ComputeWordBitsLookup(); // Transform images using census transform CensusBase = new IBitWord[ImageBase.RowCount, ImageBase.ColumnCount]; CensusMatched = new IBitWord[ImageBase.RowCount, ImageBase.ColumnCount]; WordLength = (2 * MaskHeight + 1) * (2 * MaskWidth + 1); BitWord.BitWordLength = WordLength; uint[] maskWordBase = new uint[BitWord.Byte4Length]; uint[] maskWordMatched = new uint[BitWord.Byte4Length]; BorderHeight = 1; BorderWidth = 1; // Compute max cost of census : // - max cost if all bits in mask differs (except center pixel itself), so its equal to WordLength - 1 MaxCost = WordLength - 1; // Compute census transfor for each pixel for which mask is within bounds int maxY = ImageBase.RowCount - MaskHeight, maxX = ImageBase.ColumnCount - MaskWidth; for(int x = MaskWidth; x < maxX; ++x) { for(int y = MaskHeight; y < maxY; ++y) { CensusTransform(y, x, maskWordBase, maskWordMatched); } } // For the rest let pixels outside boundary have same value as symmetricaly placed one on image // 1) Top border for(int y = 0; y < MaskHeight; ++y) for(int x = 0; x < ImageBase.ColumnCount; ++x) CensusTransform_Border(y, x, maskWordBase, maskWordMatched); // 2) Right border for(int y = MaskHeight; y < ImageBase.RowCount; ++y) for(int x = ImageBase.ColumnCount - MaskWidth; x < ImageBase.ColumnCount; ++x) CensusTransform_Border(y, x, maskWordBase, maskWordMatched); // 3) Bottom border for(int y = ImageBase.RowCount - MaskHeight; y < ImageBase.RowCount; ++y) for(int x = 0; x < maxX; ++x) CensusTransform_Border(y, x, maskWordBase, maskWordMatched); // 4) Left border for(int y = MaskHeight; y < maxY; ++y) for(int x = 0; x < MaskWidth; ++x) CensusTransform_Border(y, x, maskWordBase, maskWordMatched); }
public int GetHammingDistance(IBitWord bw) { return HammingLookup.OnesCount(Byte1to4 ^ ((BitWord_32)bw).Byte1to4) + HammingLookup.OnesCount(Byte5to8 ^ ((BitWord_32)bw).Byte5to8) + HammingLookup.OnesCount(Byte9to12 ^ ((BitWord_32)bw).Byte9to12) + HammingLookup.OnesCount(Byte13to16 ^ ((BitWord_32)bw).Byte13to16) + HammingLookup.OnesCount(Byte17to20 ^ ((BitWord_32)bw).Byte17to20) + HammingLookup.OnesCount(Byte21to24 ^ ((BitWord_32)bw).Byte21to24) + HammingLookup.OnesCount(Byte25to28 ^ ((BitWord_32)bw).Byte25to28) + HammingLookup.OnesCount(Byte29to32 ^ ((BitWord_32)bw).Byte29to32); }
public static void Update(IBitWord bw, UInt32[] bytes4) { ((BitWord_32)bw).Byte1to4 = bytes4[0]; ((BitWord_32)bw).Byte5to8 = bytes4[1]; ((BitWord_32)bw).Byte9to12 = bytes4[2]; ((BitWord_32)bw).Byte13to16 = bytes4[3]; ((BitWord_32)bw).Byte17to20 = bytes4[4]; ((BitWord_32)bw).Byte21to24 = bytes4[5]; ((BitWord_32)bw).Byte25to28 = bytes4[6]; ((BitWord_32)bw).Byte29to32 = bytes4[7]; }
public static void Update(IBitWord bw, UInt32[] bytes4) { ((BitWord_20)bw).Byte1to4 = bytes4[0]; ((BitWord_20)bw).Byte5to8 = bytes4[1]; ((BitWord_20)bw).Byte9to12 = bytes4[2]; ((BitWord_20)bw).Byte13to16 = bytes4[3]; ((BitWord_20)bw).Byte17to20 = bytes4[4]; }
public int GetHammingDistance(IBitWord bw) { return HammingLookup.OnesCount(Byte1to4 ^ ((BitWord_16)bw).Byte1to4) + HammingLookup.OnesCount(Byte5to8 ^ ((BitWord_16)bw).Byte5to8) + HammingLookup.OnesCount(Byte9to12 ^ ((BitWord_16)bw).Byte9to12) + HammingLookup.OnesCount(Byte13to16 ^ ((BitWord_16)bw).Byte13to16); }
public int GetHammingDistance(IBitWord bw) { return HammingLookup.OnesCount(Byte1to4 ^ ((BitWord_8)bw).Byte1to4) + HammingLookup.OnesCount(Byte5to8 ^ ((BitWord_8)bw).Byte5to8); }