Image compression using different compression method. This function compress image to a user defined compression level.
Arguments
- img
m x n Image Matrix converted from package jpeg's function readJPEG().
- method
Compression methods: Resize, SVD
- level
Level of compression: 1-High, 2-Med, 3-Low
Details
SVD Method: SVD (Singular Value Decomposition) on RGB image. Note: Actual image memory size is not changed from this function. It does not handle the Jpeg compression algorithm
Resize: Resize image to different size using interval pixel selection method.
Examples
img <- array(runif(1000),dim=c(10,10,3))
ImgCompress(img, method="resize", level=1)
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 0.3640484 0.2684307 0.8200561
#> [2,] 0.3395723 0.9048881 0.3656056
#> [3,] 0.2338736 0.1260044 0.4961980
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 0.9758146 0.8965214 0.1649954
#> [2,] 0.3286650 0.2445688 0.3896467
#> [3,] 0.9769948 0.8517955 0.9743758
#>
#> , , 3
#>
#> [,1] [,2] [,3]
#> [1,] 0.5189519 0.4954233 0.1892378
#> [2,] 0.9108986 0.1673321 0.8257714
#> [3,] 0.4102781 0.3504274 0.0515227
#>