summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Kazantsev <dkazanc@hotmail.com>2019-05-29 15:52:37 +0100
committerDaniil Kazantsev <dkazanc@hotmail.com>2019-05-29 15:52:37 +0100
commit7c07fde6955537085c7f7e563054aefac219a63c (patch)
treec3da29d0b476ffa31023f29f2212d52bccb8af20
parent5fb5be32360bab1b6619bcef192dde0878d014ff (diff)
downloadregularization-7c07fde6955537085c7f7e563054aefac219a63c.tar.gz
regularization-7c07fde6955537085c7f7e563054aefac219a63c.tar.bz2
regularization-7c07fde6955537085c7f7e563054aefac219a63c.tar.xz
regularization-7c07fde6955537085c7f7e563054aefac219a63c.zip
script binary save
-rw-r--r--demos/data/binary_save.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/demos/data/binary_save.py b/demos/data/binary_save.py
new file mode 100644
index 0000000..3fb2162
--- /dev/null
+++ b/demos/data/binary_save.py
@@ -0,0 +1,11 @@
+import numpy as np
+outfile = open('my_file.bin', 'wb') # Open a file for binary write
+outfile.write(im) # Write it
+outfile.flush() # Optional but a good idea
+outfile.close()
+
+# Define width and height
+w, h = 256, 256
+# Read file using numpy "fromfile()"
+with open('my_file.bin', mode='rb') as f:
+ d = np.fromfile(f,dtype=np.float32,count=w*h).reshape(h,w) \ No newline at end of file