目标:更改像素的颜色强度
代码:
using Images, ImageView;
function updateColors(path::String)
if isfile(path)
img = load(path);
chnlView = channelview(img);
chnlView[chnlView .> 0.7] = 0.9;
imshow(img);
else
info("Error: Image Not Found!");
end
end
#By Prof.Bogumił Kamiński
function quit()
print("Press q to quit!");
while true
opt = getChar();
if opt == 'q'
break
else
continue
end
end
end
#By Prof.Bogumił Kamiński
function getChar()
ret = ccall(:jl_tty_set_mode, Int32, (Ptr{Cvoid},Int32), stdin.handle, true)
ret == 0 || error("unable to switch to raw mode")
c = read(stdin, Char)
ccall(:jl_tty_set_mode, Int32, (Ptr{Cvoid},Int32), stdin.handle, false)
c
end
updateColors("/opt/julia/pictures/test.jpg");
quit();
错误:
no method matching setindexshape(::Float64, ::Int64)
请帮助我解决问题!
答案 0 :(得分:2)
您应该像这样广播分配操作:
chnlView[chnlView .> 0.7] .= 0.9