Exemplo n.º 1
0
Arquivo: Image.cs Projeto: bHimes/warp
        public void ShiftSlicesMassive(float3[] shifts)
        {
            if (IsComplex)
            {
                throw new Exception("Cannot shift complex image.");
            }

            IntPtr Data;

            if (!IsHalf)
            {
                Data = GetDevice(Intent.ReadWrite);
            }
            else
            {
                Data = GPU.MallocDevice(ElementsReal);
                GPU.OnMemoryChanged();
                GPU.HalfToSingle(GetDevice(Intent.Read), Data, ElementsReal);
            }

            GPU.ShiftStackMassive(Data,
                                  Data,
                                  DimsEffective.Slice(),
                                  Helper.ToInterleaved(shifts),
                                  (uint)Dims.Z);

            if (IsHalf)
            {
                GPU.SingleToHalf(Data, GetDevice(Intent.Write), ElementsReal);
                GPU.FreeDevice(Data);
                GPU.OnMemoryChanged();
            }
        }
Exemplo n.º 2
0
Arquivo: Image.cs Projeto: bHimes/warp
        public void Xray(float ndevs)
        {
            if (IsComplex || IsHalf)
            {
                throw new Exception("Complex and half are not supported.");
            }

            for (int i = 0; i < Dims.Z; i++)
            {
                GPU.Xray(new IntPtr((long)GetDevice(Intent.Read) + DimsEffective.ElementsSlice() * i * sizeof(float)),
                         new IntPtr((long)GetDevice(Intent.Write) + DimsEffective.ElementsSlice() * i * sizeof(float)),
                         ndevs,
                         new int2(DimsEffective),
                         1);
            }
        }
Exemplo n.º 3
0
Arquivo: Image.cs Projeto: bHimes/warp
        public void UpdateHostWithComplex(float2[][] complexData)
        {
            if (complexData.Length != Dims.Z ||
                complexData[0].Length != DimsEffective.ElementsSlice())
            {
                throw new DimensionMismatchException();
            }

            float[][] Data = GetHost(Intent.Write);

            for (int z = 0; z < Dims.Z; z++)
            {
                float[]  Slice        = Data[z];
                float2[] ComplexSlice = complexData[z];

                for (int i = 0; i < ComplexSlice.Length; i++)
                {
                    Slice[i * 2]     = ComplexSlice[i].X;
                    Slice[i * 2 + 1] = ComplexSlice[i].Y;
                }
            }
        }
Exemplo n.º 4
0
Arquivo: Image.cs Projeto: bHimes/warp
        public float2[][] GetHostComplexCopy()
        {
            if (!IsComplex)
            {
                throw new Exception("Data must be of complex type.");
            }

            float[][]  Data        = GetHost(Intent.Read);
            float2[][] ComplexData = new float2[Dims.Z][];

            for (int z = 0; z < Dims.Z; z++)
            {
                float[]  Slice        = Data[z];
                float2[] ComplexSlice = new float2[DimsEffective.ElementsSlice()];
                for (int i = 0; i < ComplexSlice.Length; i++)
                {
                    ComplexSlice[i] = new float2(Slice[i * 2], Slice[i * 2 + 1]);
                }

                ComplexData[z] = ComplexSlice;
            }

            return(ComplexData);
        }