Can't PaddedView be used to pad a grey scale or coloured image?


#1

If not then how shall I pad a non-binary image? I need this in the implementation of my radon transform code. I have been striving hard to complete the code for radon and iradon transform, your replies are awaited.
Thankyou.


#2

Something like this?

julia> im = rand(Gray, 3, 3)
3×3 Array{Gray{Float64},2}:
 Gray{Float64}(0.78866)   Gray{Float64}(0.734875)  Gray{Float64}(0.790409)
 Gray{Float64}(0.295743)  Gray{Float64}(0.66816)   Gray{Float64}(0.823026)
 Gray{Float64}(0.332627)  Gray{Float64}(0.195002)  Gray{Float64}(0.172865)

julia> PaddedView(Gray(0.5), im, (-1:5, -1:5))
PaddedViews.PaddedView{ColorTypes.Gray{Float64},2,Tuple{UnitRange{Int64},UnitRange{Int64}},Array{ColorTypes.Gray{Float64},2}} with indices -1:5×-1:5:
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.5)       …  Gray{Float64}(0.5)  Gray{Float64}(0.5)
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.5)          Gray{Float64}(0.5)  Gray{Float64}(0.5)
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.78866)      Gray{Float64}(0.5)  Gray{Float64}(0.5)
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.295743)     Gray{Float64}(0.5)  Gray{Float64}(0.5)
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.332627)     Gray{Float64}(0.5)  Gray{Float64}(0.5)
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.5)       …  Gray{Float64}(0.5)  Gray{Float64}(0.5)
 Gray{Float64}(0.5)  Gray{Float64}(0.5)  Gray{Float64}(0.5)          Gray{Float64}(0.5)  Gray{Float64}(0.5)

#3

I am using the following line of code:
PaddedView(Gray(0),image, new_tup, (pad_before[1]+1,pad_before[2]+1)), where new_tup is also a tuple of 2 elements.
But to this “MethodError” response is coming.


#4

It will be easier to help if you post a reproducible example (code that someone can just copy and paste to get the same error you’re seeing) and the full error message.


#5

Thanks @rdeits, it seems that the issue is sorted by the aid of your suggestion. It would be great if you could get me the link to this argument type PaddedView’s documentation for future reference.


#6

I was just using the documentation of the PaddedView type itself (which you can get by typing ?PaddedView in the Julia terminal). You can also see that documentation in the source code here: https://github.com/JuliaArrays/PaddedViews.jl/blob/201661159dd00c23ccca67e89aef211fad8d1d3d/src/PaddedViews.jl#L34