import numpy as np
from numpy import pi
import matplotlib.pyplot as plt
import matplotlib.image  as mpimg
from skimage.transform import resize

filename = './schrodin_yang.png'
im = mpimg.imread(filename)

n_pixels = 2**5
im = resize(im, (n_pixels, n_pixels))

data = im[:,:,0].ravel()

fig, ax = plt.subplots()
ax.imshow(im)

n_qubits = int(np.log2(len(data)))

from qiskit_aqua.components.initial_states import Custom
init_state = Custom(n_qubits, state_vector=data)

circ = init_state.construct_circuit('circuit')
qr   = circ.qregs

# circ.draw()

circ.h(qr[0][0])

from qiskit import BasicAer, execute

simulator   = BasicAer.get_backend('statevector_simulator')
sim_result  = execute(circ, simulator).result()
final_state = sim_result.get_statevector(circ)

edge   = np.real(final_state)
n_rows = int(np.sqrt(len(edge)))
n_cols = n_rows
edge   = edge.reshape(n_rows, n_cols)

edge[:,::2] = 0

fig, ax = plt.subplots(1,2)
ax[0].imshow(edge)
ax[1].imshow(im)