-1
$\begingroup$
def SSGSM(im):
   log_image=np.log(1+np.float32(im))                                                           
   gx=cv2.Sobel(log_image,cv2.CV_64F,1,0,ksize=3)
   gy=cv2.Sobel(log_image,cv2.CV_64F,1,0,ksize=3)
   ex=np.exp(-1*abs(gx))
   ey=np.exp(-1*abs(gy))
   vx=np.multiply(gx,ex)
   vy=np.multiply(gy,ey)
   vx=np.multiply(vx,vx)
   vy=np.multiply(vy,vy)
   v_=vx+vy
   v=np.sqrt(v_)
   return v

I need to convert this code into a quantum format..could anyone help me please?

$\endgroup$
0
$\begingroup$

The code I'll be referencing here is Qiskit, IBM's Quantum SDK (Software Development Kit).

First, you would have to make a circuit, so a good place to start is with the following code:

import qiskit
from qiskit import *
qc = Quantum Circuit (n, m)

where n is the number of qubits, or inputs (each the size of 1 bit) you need to do arithmetic operations on. m is the number of classical bits, or the number of 1-bit outputs you need. Unfortunately, it is more cumbersome to do arithmetic operations in quantum computing than other operations, but you can find an adder gate (an operation in qiskit) in qiskit-aqua, which you can use with the following code:

from qiskit.circuit.library import WeightedAdder
adder = WeightedAdder(num_state_qubits, weights, name)

where num_state_qubits are your input qubits, there are no weights, and name is 'adder' or whatever you want to name it.

The other arithmetic operation that's built into Qiskit is the IntegerComparison, but otherwise you have to build them yourself.

Here is a link to how to build a multiplication gate in Qiskit : https://medium.com/@sashwat.anagolum/arithmetic-on-quantum-computers-multiplication-4482cdc2d83b

For more information on how to make a Quantum Circuit in Qiskit and how to manipulate it and run it to get results, you can refer to the Qiskit Textbook and the Qiskit Documentation

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.