I am trying to learn SVD for image processing ... for example, compression.
My approach: get the image as a BufferedImage using ImageIO ... get the RGB values and use them to get the equivalent grayscale value (which is between 0-255) and save it in an array double[][]
. And use this array in SVD to compress it.
I get my USV matrices correctly ... hopefully. I get from U from AATranspose (AAT) and V from ATA.
Let me give you an example.
A is my original matrix.
A = 7.0 3.0 2.0
9.0 7.0 5.0
9.0 8.0 7.0
5.0 3.0 6.0
U = -0.34598 -0.65267 -0.59969 -0.30771
-0.57482 -0.27634 0.26045 0.72484
-0.64327 0.21214 0.44200 -0.58808
-0.36889 0.67280 -0.61415 0.18463
S = 21.57942 0.00000 0.00000
0.00000 3.35324 0.00000
0.00000 0.00000 2.02097
0.00000 0.00000 0.00000
VT = -0.70573 -0.52432 -0.47649
-0.53158 -0.05275 0.84536
-0.46838 0.84989 -0.24149
So, now I need to make an extension of the external product, leaving a few terms for compression. Let's call the shortened members k
.
k = 1 , ,
B = 6.43235 4.03003 1.70732
9.24653 6.55266 5.12711
9.41838 7.24083 7.21571
4.41866 4.05485 5.70027
, B (, , SVD) , .
A
. , 0-255. > 255 .
?
EDIT: k
- , . , k = 1
, , , :
A = u1 * S11 * vt1 + u2 * S22 + vt2
u1 u2 - 1 2 U, vt1 vt2 - 1 2 V.