From 7c07fde6955537085c7f7e563054aefac219a63c Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Wed, 29 May 2019 15:52:37 +0100 Subject: script binary save --- demos/data/binary_save.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 demos/data/binary_save.py (limited to 'demos') 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 -- cgit v1.2.3 From a532c5efb8f20a8eb400fdad0edc00dad50a5c46 Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Sun, 2 Jun 2019 13:35:52 +0100 Subject: tests run without pillow --- demos/data/binary_save.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'demos') diff --git a/demos/data/binary_save.py b/demos/data/binary_save.py index 3fb2162..06b5eb2 100644 --- a/demos/data/binary_save.py +++ b/demos/data/binary_save.py @@ -1,9 +1,9 @@ import numpy as np -outfile = open('my_file.bin', 'wb') # Open a file for binary write -outfile.write(im) # Write it +outfile = open('test_imageLena.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()" -- cgit v1.2.3