JuliaImages / ImageView.jl

Interactive display of images and movies
MIT License
136 stars 32 forks source link

csv files #241

Closed ghost closed 3 years ago

ghost commented 3 years ago

What would be the best way of visualizing images saved in .csv format?

The following doesn't work:

using CSV, ImageView
data = CSV.read("myfile.csv");
imshow(data)

This is the error:

MethodError: no method matching pixelspacing(::DataFrames.DataFrame)
Closest candidates are:
  pixelspacing(!Matched::MappedArrays.AbstractMultiMappedArray) at /Users/xxx/.julia/packages/ImageCore/yKxN6/src/traits.jl:63
  pixelspacing(!Matched::MappedArrays.AbstractMappedArray) at /Users/xxx/.julia/packages/ImageCore/yKxN6/src/traits.jl:62
  pixelspacing(!Matched::OffsetArrays.OffsetArray) at /Users/xxx/.julia/packages/ImageCore/yKxN6/src/traits.jl:67
  ...

Stacktrace:
 [1] imshow(::Any, ::Reactive.Signal{GtkReactive.ZoomRegion{RoundingIntegers.RInt64}}, ::ImageView.SliceData, ::Any; name::Any, aspect::Any) at /Users/xxx/.julia/packages/ImageView/sCn9Q/src/ImageView.jl:269
 [2] imshow(::Any; axes::Any, name::Any, aspect::Any) at /Users/xxx.julia/packages/ImageView/sCn9Q/src/ImageView.jl:260
 [3] imshow(::Any) at /Users/xxx/.julia/packages/ImageView/sCn9Q/src/ImageView.jl:259
 [4] top-level scope at In[5]:2
 [5] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091
timholy commented 3 years ago

imshow(Matrix(data)). I don't think it makes sense to support raw DataFrames since they aren't a subtype of AbstractArray.

timholy commented 3 years ago

Just FYI CSV is a terrible format choice for images. If you want a textual format then Netpbm.jl would be much better, otherwise a binary format is going to be orders of magnitude more performant.

ghost commented 3 years ago

It works. Thanks!