So I'm following this example on how to compress a picture with compressed sensing.
In the example, the picture is sparse in the Frequency domain, so the example implements a matrix that includes a DCT. That Matrix is in charge of the DCT and includes the sensing matrix.
So if we typically imply: $y=\phi x$ where $\phi$ is the sensing matrix, $x$ the samples and $y$ the resulting compressed signal.
He implies: $b=Ax$ and $A\equiv \phi \psi$ and $\psi$ converts from the spectral domain to the original domain. $b$ should, therefore, be the output ($y$).
Ok, I'm trying to apply this example to a fake case where the image is sparse in the original domain.
So I don't really need to convert to the frequency domain. Therefore I guess that my fake example shall be easier.
So I eliminated the DCT part, the Kronecker product and so on (in the example it is detailed that part). But then I got quite lost.
Maybe it's a problem of not properly understanding the process from the theoretical point of view. So, It is my understanding that, in order to apply the compressed sending, the process is as follows:
- Find the proper $\phi$ (or in my case $A$ without the $\psi$ so $A=\phi$). Ensuring the necessary properties (eg: check the coherence of the sensing matrix $\mu(\phi)$, at the end of the day you have to calculate the matrix and ensure that it will not map two inputs ($x_1$ and $x_2$, where $x_1\ne x_2$) to the same $y$).
- Convert your input, with the fresh new calculated sensing matrix
- Recover the original signal from $y$. For instance finding the signal $x$ that minimizes the $\ell_1$ norm.
Now, in the example, in a particular moment he creates the matrix $A$, as follows:
# create dct matrix operator using kron (memory errors for >large ny*nx) A = np.kron( spfft.idct(np.identity(nx), norm='ortho', axis=0), spfft.idct(np.identity(ny), norm='ortho', axis=0) ) A = A[ri,:] # same as phi times kron
As I don't really need all the DCT part I just create an identity matrix
nx*ny, and then I sample it with
ri which is basically a group of randomly selected indexes (this is how the sampling process of the original picture is done).
Cool, first problem: he makes an IDCT of the identity matrix and then he has values in the matrix, but as I pick random samples from identity matrix directly, most of the original sensing matrix is 0 values.
- Most of my sensing matrix is 0
- I did not check that the matrix is not mapping two different inputs to the same value. Indeed if the Matrix is almost 0 (or all 0), it will. Indeed it will "kill" whatever I use as an input $x$, as $y$ will always be 0.
On top of that, I don't see how it calculates the sensing matrix.
# do L1 optimization vx = cvx.Variable(nx * ny) objective = cvx.Minimize(cvx.norm(vx, 1)) constraints = [A*vx == b] prob = cvx.Problem(objective, constraints) result = prob.solve(verbose=True) Xat2 = np.array(vx.value).squeeze()
Is he using as the variable
vx is $x$, right? so, at the end of the day, is he trying to find the input that, once multiplied by the sensing matrix provides you with the output? Does it make sense?
I guess I'm misunderstanding the meaning of the above code and I don't really get what
cvx is doing there. Because I don't get how this will help to set
A and the calculate the compressed output.
So, to summarize:
- Is the general process, from the theoretical point of view, in general as described above?
- Am I wrong when I say that he is trying to find using
cvxthe input that once multiplied by
Aprovides you with the output? I guess he has to calculate the
Amatrix that will not map two different
Xinput to the same
boutput, then calculate the
bvalue with the sensing matrix and the provided input.