Example #1
0
        public void Copy(FloatImage x, FloatImage y)
        {
            Float2 *p = data;

            float *px = x.Data(0, 0);
            float *py = y.Data(0, 0);

            for (int i = 0; i < width * height; i++)
            {
                p->x = *px++;
                p->y = *py++;
                p++;
            }
        }
Example #2
0
        public void Threshold(FloatImage a, float threshold)
        {
            float *pa = a.Data(0, 0);
            byte * p  = data;

            for (int i = 0; i < width * height; i++)
            {
                if (*pa++ > threshold)
                {
                    *p++ = 255;
                }
                else
                {
                    *p++ = 0;
                }
            }
        }
Example #3
0
        public void Copy(FloatImage a, float min, float max)
        {
            float *pa = a.Data(0, 0);
            byte * p  = data;
            float  s  = 255.0f / (max - min);

            for (int i = 0; i < width * height; i++)
            {
                int value = (int)(s * (*pa++ - min));

                if (value < 0)
                {
                    *p++ = 0;
                }
                else if (value > 255)
                {
                    *p++ = (byte)255;
                }
                else
                {
                    *p++ = (byte)value;
                }
            }
        }