Hi everyone,
I was trying to rewrite the following python code:
import numpy as np
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('/home/julia_Hands_on/cat3.jpg')
img_tinted = img * [1, 0.95, 0.9]
print(img_tinted)
# Show the original image
plt.subplot(1, 2, 1)
plt.imshow(img)
# Show the tinted image
plt.subplot(1, 2, 2)
plt.imshow(np.uint8(img_tinted))
plt.show()
In julia, I wrote it as:
using Images, ImageView, Plots
img=load("/home/julia_Hands_on/cat3.jpg")
img_tinted = img * [1, 0.95, 0.9]
#gr()
but, it gives the following error:
ERROR: LoadError: DimensionMismatch("matrix A has dimensions (214,393), vector B has length 3")
Stacktrace:
[1] generic_matvecmul!(::Array{RGB{Float64},1}, ::Char, ::Array{RGB{Normed{UInt8,8}},2}, ::Array{Float64,1}, ::LinearAlgebra.MulAddMul{true,true,Bool,Bool}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/matmul.jl:609
[2] mul! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/matmul.jl:81 [inlined]
[3] mul! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/matmul.jl:203 [inlined]
[4] *(::Array{RGB{Normed{UInt8,8}},2}, ::Array{Float64,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/matmul.jl:51
[5] top-level scope at /home/g2-test/julia_Hands_on/python_julia/numpy_conversion.jl:56
[6] include at ./boot.jl:328 [inlined]
[7] include_relative(::Module, ::String) at ./loading.jl:1105
[8] include(::Module, ::String) at ./Base.jl:31
[9] include(::String) at ./client.jl:424
[10] top-level scope at REPL[1]:1
in expression starting at /home/g2-test/julia_Hands_on/python_julia/numpy_conversion.jl:3
The python code ran without any errors. Why is it showing error for julia? Can someone help me.