public void Copy(ByteImage a, float scale) { byte* pa = a.Data(0, 0); float* p = data; for (int i = 0; i < width * height; i++) *p++ = *pa++ * scale; }
public void Copy(ByteImage byteImage) { byte* p = byteImage.Data(0, 0); RGB24* pOut = data; for (int i = 0; i < width * height; i++) { pOut->R = pOut->G = pOut++->B = *p++; } }
public void Copy(ByteImage a, float scale) { byte * pa = a.Data(0, 0); float *p = data; for (int i = 0; i < width * height; i++) { *p++ = *pa++ *scale; } }
public void Copy(ByteImage byteImage) { byte * p = byteImage.Data(0, 0); RGB24 *pOut = data; for (int i = 0; i < width * height; i++) { pOut->R = pOut->G = pOut++->B = *p++; } }
public void Add(ByteImage a) { byte * pa = a.Data(0, 0); float *p = data; for (int i = 0; i < width * height; i++) { *p = *p + *pa; p++; pa++; } }
public void And(ByteImage a) { byte *p_a = a.Data(0, 0); byte *p = data; for (int i = 0; i < width * height; i++) { *p = (byte)((*p_a) & (*p)); p++; p_a++; } }
public void Add(ByteImage a) { byte * p_a = a.Data(0, 0); ushort *p = data; for (int i = 0; i < width * height; i++) { *p = (ushort)((*p_a) + (*p)); p++; p_a++; } }
public void Decimate(ByteImage a, int factor) { byte *output = data; for (int y = 0; y < height; y++) { byte *pa = a.Data(0, y * factor); for (int x = 0; x < width; x++) { *output++ = *pa; pa += factor; } } }
public void XMirror(ByteImage a) { byte *pOut = data; byte *pIn = a.data; for (int yy = 0; yy < height; yy++) { pIn = a.Data(width - 1, yy); for (int xx = 0; xx < width; xx++) { *pOut++ = *pIn--; } } }
public void Decimate(ByteImage a, int factor) { byte* output = data; for (int y = 0; y < height; y++) { byte* pa = a.Data(0, y * factor); for (int x = 0; x < width; x++) { *output++ = *pa; pa += factor; } } }
public void CopyRectangle(ByteImage byteImage, int startX, int startY, int w, int h) { byte * pOrig = byteImage.Data(0, 0); ARGB32 *pOutOrig = data; byte * p; ARGB32 *pOut; for (int j = startY; j < h; j++) { for (int i = startX; i < w; i++) { p = pOrig + j * byteImage.Width + i; pOut = pOutOrig + j * width + i; pOut->A = 255; pOut->R = pOut->G = pOut->B = *p; } } }
public void CopyRectangle(ByteImage byteImage, int startX, int startY, int w, int h) { byte* pOrig = byteImage.Data(0, 0); ARGB32* pOutOrig = data; byte* p; ARGB32* pOut; for (int j = startY; j < h; j++) { for (int i = startX; i < w; i++) { p = pOrig + j * byteImage.Width + i; pOut = pOutOrig + j * width + i; pOut->A = 255; pOut->R = pOut->G = pOut->B = *p; } } }
// BEWARE: threshold on absdiff, and mask level settings* public unsafe void Decode(ByteImage[] capturedImages, ShortImage decoded, ByteImage mask, int nBits, int max) { decoded.Zero(); int capturedWidth = decoded.Width; int capturedHeight = decoded.Height; // stores decoded bit from previous level var bits = new ByteImage(capturedWidth, capturedHeight); for (int i = 0; i < nBits; i++) { var capturedImage = capturedImages[2 * i]; var invertedCapturedImage = capturedImages[2 * i + 1]; int bitValue = (int)Math.Pow(2.0, nBits - i - 1); ushort *decodedp = decoded.Data(0, 0); byte * capturedp = capturedImage.Data(0, 0); byte * invertedp = invertedCapturedImage.Data(0, 0); byte * maskp = mask.Data(0, 0); byte * bitsp = bits.Data(0, 0); for (int y = 0; y < capturedHeight; y++) { for (int x = 0; x < capturedWidth; x++) { // a bit is considered valid if the diff is greater than some threshold; this value is tricky to set given AGC byte valid = (Math.Abs(*capturedp - *invertedp) > 10) ? (byte)255 : (byte)0; byte bit = (*capturedp >= *invertedp) ? (byte)255 : (byte)0; // Gray code bit *bitsp = (byte)(bit ^ *bitsp); if (*bitsp == 255) { *decodedp = (ushort)(*decodedp + bitValue); } // stop updating the mask for the least significant levels (but continue decoding) // *FIX: this is pretty fragile, perhaps better to record how many bits of rows and column have been recorded and walk back from that if (i < nBits - 4) { *maskp = (byte)(valid & (*maskp)); } decodedp++; capturedp++; invertedp++; maskp++; bitsp++; } } } bits.Dispose(); // check that decoded values are within range for (int y = 0; y < capturedHeight; y++) { for (int x = 0; x < capturedWidth; x++) { int d = decoded[x, y]; // can this be negative? if ((d >= max) || (d < 0)) { mask[x, y] = 0; } } } }
// BEWARE: threshold on absdiff, and mask level settings* public unsafe void Decode(ByteImage[] capturedImages, ShortImage decoded, ByteImage mask, int nBits, int max) { decoded.Zero(); int capturedWidth = decoded.Width; int capturedHeight = decoded.Height; // stores decoded bit from previous level var bits = new ByteImage(capturedWidth, capturedHeight); for (int i = 0; i < nBits; i++) { var capturedImage = capturedImages[2 * i]; var invertedCapturedImage = capturedImages[2 * i + 1]; int bitValue = (int)Math.Pow(2.0, nBits - i - 1); ushort* decodedp = decoded.Data(0, 0); byte* capturedp = capturedImage.Data(0, 0); byte* invertedp = invertedCapturedImage.Data(0, 0); byte* maskp = mask.Data(0, 0); byte* bitsp = bits.Data(0, 0); for (int y = 0; y < capturedHeight; y++) for (int x = 0; x < capturedWidth; x++) { // a bit is considered valid if the diff is greater than some threshold; this value is tricky to set given AGC byte valid = (Math.Abs(*capturedp - *invertedp) > 10) ? (byte)255 : (byte)0; byte bit = (*capturedp >= *invertedp) ? (byte)255 : (byte)0; // Gray code bit *bitsp = (byte)(bit ^ *bitsp); if (*bitsp == 255) *decodedp = (ushort)(*decodedp + bitValue); // stop updating the mask for the least significant levels (but continue decoding) // *FIX: this is pretty fragile, perhaps better to record how many bits of rows and column have been recorded and walk back from that if (i < nBits - 4) *maskp = (byte)(valid & (*maskp)); decodedp++; capturedp++; invertedp++; maskp++; bitsp++; } } bits.Dispose(); // check that decoded values are within range for (int y = 0; y < capturedHeight; y++) for (int x = 0; x < capturedWidth; x++) { int d = decoded[x, y]; // can this be negative? if ((d >= max) || (d < 0)) mask[x, y] = 0; } }