Computer Vision News - July 2018

The code below demonstrates the image reconstruction process: Lines 1-2 import the needed libraries. Line 3 loads the corrupted image. Line 4 loads the a 0-1 matrix called corr_index , which has a value of 1 for uncorrupted pixels and 0 otherwise. Line 6 defines a CVXPY variable class the size of the image -- the value field of this class holds the in-painted image. will hold the in-painted image. Line 7 defines a total variance minimizer. Line 8 defines the constraint that all pixels with a corr-index value of 1 must remain unchanged. Line 9-10 define the problem instance and run the solver to solve it. Once the solver converges, the matrix U.value contains the in-painted image. As in the least-squares problem we define the objective function we want to minimize, which is a sum of squares of A*x-b Last but not least, colab! All you need to do is go to colab.research.google.com/ , open a new notebook, write and run your code. However, two things will be missing: 1. The CVXPY library, which is not a built-in Python package. You need to install it, which can be done by the following command: !pip install cvxpy (Yes, you can run this pip command even though this is a web service). 2. Obviously, images and other files to work on will be missing. 6 Tool Computer Vision News CVXPY and Colaboratory 1. import matplotlib.pyplot as plt 2. import numpy as np 3. corr_img = np.array(Image.open("data/lena512_corrupted.png")) 4. corr_index = Image.open("data/lena512_corr_index.png") 5. rows, cols = Uorig.shape 6. U = Variable(shape=(rows, cols)) 7. obj = Minimize(tv(U)) 8. constraints = [multiply(corr_index , U) == multiply(corr_index , corr_img )] 9. prob = Problem(obj, constraints) 10. prob.solve(solver=SCS)

RkJQdWJsaXNoZXIy NTc3NzU=