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

**URL:** <https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498>\
**Category:** Visualization\
**Created:** [March 5, 2018, 6:57am UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498 "2018-03-05T06:57:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tosalonijain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tosalonijain/32/3624_2.png) [@tosalonijain](https://discourse.julialang.org/u/tosalonijain)\
**Post date:** [March 5, 2018, 6:57am UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498/1 "2018-03-05T06:57:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [March 5, 2018, 7:13am UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498/2 "2018-03-05T07:13:02Z")

</div>

Something like this?

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![tosalonijain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tosalonijain/32/3624_2.png) [@tosalonijain](https://discourse.julialang.org/u/tosalonijain)\
**Post date:** [March 5, 2018, 7:32am UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498/3 "2018-03-05T07:32:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [March 5, 2018, 3:18pm UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498/4 "2018-03-05T15:18:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tosalonijain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tosalonijain/32/3624_2.png) [@tosalonijain](https://discourse.julialang.org/u/tosalonijain)\
**Post date:** [March 5, 2018, 4:48pm UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498/5 "2018-03-05T16:48:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [March 5, 2018, 5:35pm UTC](https://discourse.julialang.org/t/cant-paddedview-be-used-to-pad-a-grey-scale-or-coloured-image/9498/6 "2018-03-05T17:35:29Z")

</div>

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](https://github.com/JuliaArrays/PaddedViews.jl/blob/201661159dd00c23ccca67e89aef211fad8d1d3d/src/PaddedViews.jl#L34)
