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.1358010 0.06683668 0.9958336
#> [2,] 0.6937541 0.22067132 0.8659513
#> [3,] 0.5974855 0.98194194 0.7109607
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 0.7708132 0.5095722 0.5975656
#> [2,] 0.7172949 0.5062194 0.6887570
#> [3,] 0.6133708 0.5285507 0.7667520
#>
#> , , 3
#>
#> [,1] [,2] [,3]
#> [1,] 0.05447419 0.8793865 0.8341927
#> [2,] 0.63235610 0.9291983 0.7622400
#> [3,] 0.20289037 0.3967250 0.2561088
#>