using PyPlot
# 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")
# 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")