The ClearMage code aims to optimize a low-res image using a linear algebra algorithm.
Before running the code, ensure that you have the following:
- MATLAB: The code is written in MATLAB, so make sure you have MATLAB installed on your system. Alternatively, you can use the online version of MATLAB available at MATLAB Online.
To use the code, follow these steps:
- Open MATLAB on your system or access MATLAB Online on your web browser.
- Create a new MATLAB script or open an existing one.
- Copy and paste the provided code into the script.
The code performs the following steps:
- It starts by clearing the MATLAB workspace, closing any open figures, and clearing the command window.
- The contaminated image is read using the
imread
function and stored in the variableXc
. This assumes that there is an image file named 'stones_c.jpg' in the MATLAB working directory. - The image is converted to double precision and stored in the variable
Xc1
. - The original contaminated image is displayed using the
imshow
function. - The image optimization process begins. The following steps are performed:
- A vector of ones,
a
, is created with 400 rows and 1 column. - Two matrices,
D1
andD2
, are created using thespdiags
function. These matrices have dimensions 400x300. - The value of
d
is set to 2. - The equation
Ax + xB = c
is solved using thelyap
function, whereA
is a 300x300 matrix,B
is a 300x300 matrix, andC
is a matrix obtained by negatingXc1
. - The resulting optimized image,
X
, is converted back to uint8 format and stored in the variableX1
.
- A vector of ones,
- Finally, the optimized image is displayed using the
imshow
function.
For a more detailed explanation and additional information, refer to the image_optimization.pdf
file included in this repository.