Unexpected "="

This segment of Julia code filters keypoints in an image by an interpolation of the fields in the extremum from a difference of gaussian scale space.

mutable struct discrete_extremum
    o
    s
    m
    n
    intensity
end
mutable struct candidateKeypoint
    oE
    s
    m
    n
    σ
    x
    y
    ω
end

LB = Array{candidateKeypoint}(0)
for extremum in LA′
    for i = 1:5
        H̄ = Hessian(extremum.o, extremum.s, extremum.m, extremum.n)
        ḡ = ThreeDgradient(extremum.o, extremum.s, extremum.m, extremum.n)
        α⋆ = alphaStar(H̄, ḡ)
        ω = omega(H̄, ḡ, extremum.o, extremum.s, extremum.m, extremum.n)
        δOE = δMin * 2^(extremum.o - 1)
        α1⋆ = α⋆[1]
        α2⋆ = α⋆[2]
        α3⋆ = α⋆[3]
        σ = (δOE/δMin) * σMin * 2^((α1⋆ + extremum.s)/nSpo)
        x = δOE * (α2⋆ + extremum.m)
        y = δOE * (α2⋆ + extremum.n)
        extremum.s, extremum.m, extremum.n = round(Int64, extremum.s + α1⋆), round(Int64, extremum.m + α2⋆), round(Int64, extremum.n + α3⋆)
        if max(abs(α1⋆), abs(α2⋆), abs(α3⋆)) < 0.6
            break
        end
    end
    if max(abs(α1⋆), abs(α2⋆), abs(α3⋆)) < 0.6
        push!(LB, candidateKeypoint(extremum, σ, x, y, ω))
    end
end

I am getting this error:

syntax: unexpected “=”

in the part starting with LB =
There is no line number mentioned. Can you guys suggest what I am doing wrong?

OK, sorry, I wasn’t concentrating enough, due to the special characters, I guess. Perhaps Julia behave in the same way? I have not used special characters in a code, so I can’t answer about it.

1 Like

Hi @LeoK987! Thanks for the help.
It’s just after the two structure definitions. Should I remove the special characters from variable names?

You can just say:

LB = candidateKeypoint[]

Which initializes an empty candidateKeypoint Vector.

It is not LB = that is giving you grief. Instead it is the ‘⋆’ character in the variables α1⋆, α2⋆, and α3⋆. I don’t know why.

If you inspect line 28 in file julia/julia-parser.scm at master · JuliaLang/julia · GitHub you’ll find that the ‘⋆’ character is defined as an operator with the same precedence as the ‘*’ operator. That is why the Julia parser reports that the ‘=’ character is unexpected. It expects another operand.

Please don’t double post, especially without cross referencing: image processing - syntax: unexpected "=" in Julia - Stack Overflow

1 Like

Oh sorry I forgot to put the reference! My bad!

@quinnj already posted an alternative, but I expect this to fail, since Array{candidateKeypoint} is an abstract type.

Use Array{.., 1}() or Vector{..}() (in my view better), or, as suggested, T[].

This is the reason I always prefer Vector and Matrix over Array{ ..,1} and Array{..,2}. More readable, and less likely to mistype.

1 Like