Skip to content

Commit

Permalink
Utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
szou28 committed Nov 21, 2017
1 parent 1b3b289 commit a20fce8
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,7 @@
import numpy as np
import cv2

<<<<<<< HEAD
class UArray(object):
=======
def ToDoubleArray(point):
result = Array.CreateInstance(Double, point.Length)
i = 0
while i < point.Length:
result[i] = point[i]
i += 1
return result

ToDoubleArray = staticmethod(ToDoubleArray)

# NB: Python and our script treat 'float' arrays as C# doubles!
# Hence 8 byte offets!
def ToDoubleArray(point):
result = Array.CreateInstance(Double, point.Length / 8)
n = 0
while n < point.Length:
result[n / 8] = BitConverter.ToDouble(point, n)
n += 8
return result

ToDoubleArrayFromDoubleBytes = staticmethod(ToDoubleArrayFromDoubleBytes)

def ToDoubleArray(point):
result = Array.CreateInstance(Double, point.Length)
i = 0
while i < point.Length:
result[i] = point[i]
i += 1
return result

ToDoubleArrayFromInt8Bytes = staticmethod(ToDoubleArrayFromInt8Bytes)

def ToDoubleArray(point, sourceIndex, length):
result = [None] * length
i = 0
while i < length:
result[i] = point[sourceIndex + i]
i += 1
return result

ToDoubleArray = staticmethod(ToDoubleArray)

def ToByteArray(point):
bytes = Array.CreateInstance(Byte, point.Length)
i = 0
while i < point.Length:
bytes[i] = 255 if point[i] > 255f else (0 if point[i] < 0f else M.Round(point[i]))
i += 1
return bytes

ToByteArray = staticmethod(ToByteArray)

def ToIntArray(array):
intArray = Array.CreateInstance(int, array.Length)
i = 0
while i < array.Length:
intArray[i] = array[i]
i += 1
return intArray

ToIntArray = staticmethod(ToIntArray)

def ToRGBArray(array, scale, offset):
""" <summary>
output[i] = input[i]*scale + offset
</summary>
<param name="array"></param>
<param name="scale"></param>
<param name="offset"></param>
<returns></returns>
"""
result = Array.CreateInstance(int, array.Length)
i = 0
while i < array.Length:
result[i] = UMath.Clamp(array[i] * scale + offset, 0.0, 255.0)
i += 1
return result
>>>>>>> ce3bbda448a92936f8dccbf2cd8bde79d66d5fb4

@staticmethod
def ToDoubleArray(arr, sourceIndex=0, length=None):
Expand Down

0 comments on commit a20fce8

Please sign in to comment.