Skip to content

Commit

Permalink
Discourage convert(Array{C}, img) in favor of broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Aug 26, 2020
1 parent 4c5f204 commit 5f75e41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/examples/contours/contour_detection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ end
function find_contours(image)
nbd = 1
lnbd = 1
image = convert(Array{Float64}, image)
image = Float64.(image)
contour_list = Vector{typeof(CartesianIndex[])}()
done = [false, false, false, false, false, false, false, false]

Expand Down
7 changes: 3 additions & 4 deletions docs/src/tutorials/arrays_colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ julia> a = [1,2,3,4]
4
```

then all of the following create a new array where the element type is `Float64`:
then either of the following creates a new array where the element type is `Float64`:

```julia
convert(Array{Float64}, a)
map(Float64, a)
Float64.(a) # short for broadcast(Float64, a)
```
Expand Down Expand Up @@ -184,7 +183,7 @@ tools. For example, certain C libraries permit or prefer the order of
the color channels to be different:

```julia
julia> dump(convert(BGR, c))
julia> dump(BGR(c))
ColorTypes.BGR{Float32}
b: Float32 0.65485954
g: Float32 0.9650581
Expand All @@ -195,7 +194,7 @@ or even to pack the red, green, and blue colors---together with a
dummy "alpha" (transparency) channel---into a single 32-bit integer:

```julia
julia> c24 = convert(RGB24, c); dump(c24)
julia> c24 = RGB24(c); dump(c24)
ColorTypes.RGB24
color: UInt32 12711591

Expand Down

0 comments on commit 5f75e41

Please sign in to comment.