Something like this?
julia> field = rand(5,5);
julia> rr2(index, center) = sum((Tuple(index) .- center).^2)
rr2 (generic function with 1 method)
julia> rr2.(CartesianIndices(field), (size(field)./2 .+ 0.5,))
5×5 Array{Float64,2}:
8.0 5.0 4.0 5.0 8.0
5.0 2.0 1.0 2.0 5.0
4.0 1.0 0.0 1.0 4.0
5.0 2.0 1.0 2.0 5.0
8.0 5.0 4.0 5.0 8.0
The key with broadcasting in general is to build the scalar function first. I think where you’re having difficulty is that you were trying to get rr2 to operate on the array. Instead, figure out the computation for one pixel, then pass what you need to it (in this case, the CartesianIndices and the center). When you combine this with other broadcast expressions like you have there, it won’t allocate intermediaries.