# Error in Images.jl example code

**URL:** <https://discourse.julialang.org/t/error-in-images-jl-example-code/3739>\
**Category:** General Usage\
**Tags:** package\
**Created:** [May 16, 2017, 8:24am UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739 "2017-05-16T08:24:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![phlavenk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phlavenk/32/1873_2.png) [@phlavenk](https://discourse.julialang.org/u/phlavenk)\
**Post date:** [May 16, 2017, 8:24am UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739/1 "2017-05-16T08:24:06Z")

</div>

I’ve tried the example code found in documentation of Images.jl  
[Image-algorithms](http://juliaimages.github.io/latest/function_reference.html#Image-algorithms-1) for the `warp` function. Unfortunately the code does emit error:

```julia
using Images, CoordinateTransformations, TestImages, OffsetArrays
img = testimage("lighthouse")
indices(img)
# Rotate around the center of `img`
tfm = recenter(RotMatrix(pi/4), center(img))
imgw = warp(img, tfm)
indices(imgw)
# Alternatively, specify the origin in the image itself
img0 = OffsetArray(img, -30:481, -384:383); # origin near top of image
rot = LinearMap(RotMatrix(pi/4))
#LinearMap([0.707107 -0.707107; 0.707107 0.707107])
imgw = warp(img0, rot);
indices(imgw)
#(-293:612,-293:611)
imgr = parent(imgw);
indices(imgr)

```

```julia
size not supported for arrays with indices (-30:481,-384:383); see http://docs.julialang.org/en/latest/devdocs/offset-arrays/

 in errmsg(::OffsetArrays.OffsetArray{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2,Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}}) at C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\JuliaPro-0.5.1.1\pkgs-0.5.1.1\v0.5\OffsetArrays\src\OffsetArrays.jl:48
 in interpolate at C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\JuliaPro-0.5.1.1\pkgs-0.5.1.1\v0.5\Interpolations\src\b-splines\b-splines.jl:53 [inlined]
 in interpolate at C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\JuliaPro-0.5.1.1\pkgs-0.5.1.1\v0.5\Interpolations\src\b-splines\b-splines.jl:57 [inlined]
 in warp(::OffsetArrays.OffsetArray{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2,Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}}, ::CoordinateTransformations.LinearMap{Rotations.RotMatrix{2,Float64,4}}) at C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\JuliaPro-0.5.1.1\pkgs-0.5.1.1\v0.5\ImageTransformations\src\ImageTransformations.jl:28

```

I’m using JuliaPro on windows7 64-bit:

```julia
Julia Version 0.5.1
Commit 6445c82 (2017-03-05 13:25 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

177 required packages:
 - ASTInterpreter 0.0.4
 - AbstractTrees 0.0.4
 - ArgParse 0.4.0
 - Atom 0.5.9
 - AutoGrad 0.0.6
 - AutoHashEquals 0.1.1
 - AxisAlgorithms 0.1.6
 - AxisArrays 0.0.4
 - BenchmarkTools 0.0.7
 - BinDeps 0.4.7
 - Blink 0.5.1
 - Blosc 0.2.0
 - BufferedStreams 0.3.0
 - BusinessDays 0.6.1
 - COFF 0.0.2
 - CRC 1.2.0
 - CSV 0.1.2
 - Calculus 0.2.0
 - CatIndices 0.0.2
 - CategoricalArrays 0.1.2
 - Clustering 0.7.0
 - CodeTools 0.4.3
 - Codecs 0.3.0
 - ColorTypes 0.3.4
 - ColorVectorSpace 0.4.0
 - Colors 0.7.3
 - Combinatorics 0.3.2
 - Compat 0.19.0
 - Compose 0.4.5
 - ComputationalResources 0.0.2
 - Conda 0.5.1
 - Contour 0.2.0
 - CoordinateTransformations 0.4.0
 - CustomUnitRanges 0.0.4
 - DBAPI 0.0.3
 - DSP 0.1.1
 - DWARF 0.1.0
 - DataArrays 0.3.12
 - DataFrames 0.8.5
 - DataStreams 0.1.2
 - DataStructures 0.5.3
 - DecisionTree 0.5.1
 - DiffBase 0.0.4
 - Distances 0.4.1
 - Distributions 0.12.1
 - DualNumbers 0.2.3
 - ELF 0.1.0
 - EzXML 0.4.3
 - FFTViews 0.0.2
 - FileIO 0.3.0
 - FixedPointNumbers 0.3.4
 - FixedSizeArrays 0.2.5
 - Formatting 0.2.0
 - ForwardDiff 0.3.4
 - GLM 0.6.1
 - GLVisualize 0.2.2
 - GR 0.19.0
 - GZip 0.2.20
 - Gadfly 0.5.3
 - Gallium 0.0.4
 - Graphics 0.1.4
 - HDF5 0.7.3
 - Hexagons 0.0.4
 - Hiccup 0.1.1
 - HttpCommon 0.2.6
 - HttpParser 0.2.0
 - HttpServer 0.1.7
 - HypothesisTests 0.4.0
 - IJulia 1.4.1
 - ImageAxes 0.1.1
 - ImageCore 0.1.4
 - ImageFiltering 0.1.2
 - ImageMagick 0.2.2
 - ImageMetadata 0.2.1
 - ImageTransformations 0.1.0
 - Images 0.8.0
 - IndirectArrays 0.1.1
 - Interact 0.4.3
 - Interpolations 0.3.7
 - IntervalSets 0.0.3
 - Iterators 0.3.0
 - JDBC 0.1.0
 - JLD 0.6.9
 - JSON 0.8.3
 - JavaCall 0.4.2
 - JuMP 0.16.0
 - JuliaParser 0.7.4
 - JuliaWebAPI 0.2.1
 - Juno 0.2.7
 - KernelDensity 0.3.2
 - Knet 0.8.2
 - LNR 0.0.2
 - LaTeXStrings 0.2.0
 - Lazy 0.11.5
 - LegacyStrings 0.2.0
 - LibExpat 0.2.4
 - Libz 0.2.4
 - LightGraphs 0.7.3
 - LightXML 0.4.0
 - LineSearches 0.1.5
 - Loess 0.1.0
 - Logging 0.3.1
 - LsqFit 0.2.0
 - MLBase 0.6.1
 - MNIST 0.0.2
 - MXNet 0.2.1
 - MachO 0.0.4
 - MacroTools 0.3.6
 - MappedArrays 0.0.6
 - MathProgBase 0.6.1
 - MbedTLS 0.4.3
 - Measures 0.0.3
 - Media 0.2.5
 - Mocha 0.2.0
 - Mustache 0.1.3
 - Mux 0.2.3
 - NaNMath 0.2.2
 - NearestNeighbors 0.2.0
 - Nettle 0.3.0
 - NullableArrays 0.1.0
 - ODBC 0.5.1
 - ObjFileBase 0.0.4
 - OffsetArrays 0.2.14
 - Optim 0.7.7
 - PDMats 0.5.6
 - ParallelDataTransfer 0.1.1
 - Parameters 0.6.0
 - ParserCombinator 1.7.11
 - PlotlyJS 0.5.2
 - Plots 0.10.3
 - PolynomialFactors 0.0.3
 - Polynomials 0.1.3
 - PositiveFactorizations 0.0.4
 - Primes 0.1.2
 - ProgressMeter 0.3.3
 - ProtoBuf 0.3.2
 - PyCall 1.10.0
 - PyPlot 2.3.1
 - QuadGK 0.1.1
 - QuantEcon 0.9.0
 - RCall 0.6.4
 - RangeArrays 0.1.2
 - Ratios 0.0.4
 - Reactive 0.3.7
 - Reexport 0.0.3
 - Requests 0.4.1
 - Requires 0.3.0
 - ReverseDiffSparse 0.7.1
 - Rmath 0.1.6
 - Roots 0.3.0
 - Rotations 0.3.5
 - SHA 0.3.2
 - SIUnits 0.1.0
 - ScikitLearnBase 0.2.2
 - ShowItLikeYouBuildIt 0.0.1
 - Showoff 0.0.7
 - SimpleTraits 0.3.0
 - SortingAlgorithms 0.1.0
 - SpecialFunctions 0.1.1
 - StaticArrays 0.3.0
 - StatsBase 0.13.1
 - StatsFuns 0.4.0
 - StructIO 0.0.2
 - TerminalUI 0.0.2
 - TestImages 0.2.0
 - TexExtensions 0.0.3
 - TextWrap 0.1.6
 - TiledIteration 0.0.2
 - URIParser 0.1.8
 - Unitful 0.1.4
 - VT100 0.1.0
 - WeakRefStrings 0.2.0
 - WebSockets 0.2.1
 - WinRPM 0.2.3
 - WinReg 0.2.0
 - WoodburyMatrices 0.2.2
 - ZMQ 0.4.1
17 additional packages:
 - DocStringExtensions 0.3.1
 - FreeType 1.2.0
 - GLAbstraction 0.3.1
 - GLFW 1.3.0
 - GLWindow 0.3.2
 - GeometryTypes 0.2.2
 - MeshIO 0.0.6
 - ModernGL 0.1.1
 - Packing 0.0.4
 - PlotThemes 0.1.1
 - PlotUtils 0.3.0
 - Quaternions 0.1.1
 - Ranges 0.0.1
 - RecipesBase 0.1.0
 - SignedDistanceFields 0.1.0
 - UnicodeFun 0.0.2
 - ZipFile 0.3.0

```

Is this funcionality supported only on Julia 0.6? Could somebody please point me to the code location i could try to improve? I must admit I’m still new to the rewritten Images.jl.

Thank you a lot.  
Petr

---

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [May 16, 2017, 11:12am UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739/2 "2017-05-16T11:12:18Z")

</div>

For non-1 indices arrays you need Interpolations v0.4.0 or higher.

Really, the whole `warp` functionality is rather new and still actively developed, so your are likely required to be on the latest 0.5 compatible versions of the Image related packages.

Things do work on 0.5, but I know little about what that means for JuliaPro

---

<div class="post-metadata">

**Author:** ![phlavenk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phlavenk/32/1873_2.png) [@phlavenk](https://discourse.julialang.org/u/phlavenk)\
**Post date:** [May 16, 2017, 5:20pm UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739/3 "2017-05-16T17:20:11Z")

</div>

I’ve updated all packages to latest stable versions, but the error remains and is restricted to image output in Jupyter via show function (from Images.jl).  
I’ve found the possible cause for the error. Its mentioned in [https://github.com/JuliaArrays/OffsetArrays.jl#special-note-for-julia-05](https://github.com/JuliaArrays/OffsetArrays.jl#special-note-for-julia-05)

> During the transition during Julia 0.5 to allowing arrays with arbitrary indices, certain operations (like size and length) are deliberately unsupported; see the documentation describing the reasoning behind this decision. The general recommendation is to use indices and linearindices for most operations where size and length would have formerly been used.

And this is exactly what function `Base.show{C<:Colorant}(io::IO, mime::MIME"image/png", img::AbstractMatrix{C};....` in Images.jl is doing.  
I’m not sure it has any workaround other than to wait for 0.6 release.

---

<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:** [May 16, 2017, 7:58pm UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739/4 "2017-05-16T19:58:46Z")

</div>

> I’m not sure it has any workaround other than to wait for 0.6 release.

The workaround is that we fix the `downsize_for_thumbnail()` function, which should be pretty easy. The `OffsetArrays.jl` readme which you linked has a hint that we can use:

Try editing `Images/src/showmime.jl` to change

```julia
a, b = size(img)

```

to

```julia
a, b = map(size, indices(img))

```

(you’ll need to restart your IJulia kernel after doing this).

Does that resolve the issue?

---

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [May 17, 2017, 11:42am UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739/5 "2017-05-17T11:42:56Z")

</div>

> [@phlavenk](#):
>
> I’ve updated all packages to latest stable versions, but the error remains and is restricted to image output in Jupyter via show function (from Images.jl).

> [@phlavenk](#):
>
> I’m not sure it has any workaround other than to wait for 0.6 release.

I am working with Images a lot and I am on 0.5.0 on my big machine. So I am sure it works on 0.5. My guess is you have some packages that are pinned on older versions. Maybe someone familiar with JuliaPro knows more about that aspect

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [May 23, 2017, 12:18pm UTC](https://discourse.julialang.org/t/error-in-images-jl-example-code/3739/6 "2017-05-23T12:18:34Z")

</div>

The demo works for me on both Julia 0.5 and 0.6. As @Evizero suggested, check `Pkg.status()` and see if you have some old package versions due to “dirty” or pinned packages. Prior to 0.5.2, there were also some resolver issues that prevented one from running the latest code in JuliaImages.
