I am using the gray version of the mandrill image from the Julia TestImage packages. This is the result. Attached is the image after I use 5 singular values.

@Desmond it’s easier to help if you can provide a reproducible example that people can copy-and-paste.

import TestImages
import Images
import ImageInTerminal
import LinearAlgebra
function rsvd(X, k)
m, n = size(X)
Φ = rand(n, k)
Y = X * Φ
Q, R = LinearAlgebra.qr(Y)
Qm = Matrix(Q)
B = Qm' * X
Uhat, S, Vt = LinearAlgebra.svd(B)
Uk = Uhat[:, 1:k]
Vk = Vt'[1:k, :]
U = Qm * Uk
return U * LinearAlgebra.Diagonal(S) * Vk
end
image = TestImages.testimage("mandrill")
gray_image = Images.Gray.(image);
image_matrix = Images.channelview(gray_image);
M = rsvd(image_matrix, 5);
Images.colorview(Images.Gray, M)

using LinearAlgebra
using FundamentalsNumericalComputation
using TestImages
using Images
image=TestImages.testimage("mandrill")
grayimg=Gray.(image
X=channelview(grayimg)
function rsvd(X,k)
(m,n)=size(X)
Phi=rand(n,k)
Y=X*Phi
Q,R = qr(Y)
B=transpose(Matrix(Q))*X
Uhat,S,Vt=svd(B)
Uk=Uhat[:, 1:k]
Vk=Vt'[1:k, :]
U=Matrix(Q)*Uk
M = U * diagm(S) * Vk
return M
end
M=rsvd(X,5)
Gray.(M)