In [1]:
using PyPlot
In [2]:
# Reading a binary file 

# Download file from website into your current directory 

 download("http://seismic.physics.ualberta.ca/data/finger.bin","finger.bin");

# Read data

 file_to_read = "finger.bin"
 fid = open(file_to_read,"r");
 n1 = 2165
 n2 = 1528
 
 N = n1*n2
 data = zeros(Float64,N);
 read!(fid,data);
 close(fid)

 d = reshape(data,n1,n2);
 imshow(d, cmap="gray")
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 16 25.2M   16 4253k    0     0  48.4M      0 --:--:-- --:--:-- --:--:-- 48.2M
100 25.2M  100 25.2M    0     0  71.7M      0 --:--:-- --:--:-- --:--:-- 71.7M
Out[2]:
PyObject <matplotlib.image.AxesImage object at 0x11c196750>
In [3]:
# How write a binary file and read it back...

# Mask the data 

 d[300:400,500:1110] .= 0;
 tmp = d[:]
 file_to_write = "tmp.bin"
 fid = open(file_to_write,"w");
 write(fid,tmp)
 close(fid)

# And now read it again 

 fid = open(file_to_write,"r");
 n1 = 2165
 n2 = 1528
 
 N = n1*n2
 data2 = zeros(Float64,N);
 read!(fid,data2);
 close(fid)

 d=reshape(data2,n1,n2);
 imshow(d, cmap="gray")
Out[3]:
PyObject <matplotlib.image.AxesImage object at 0x11ff08810>