Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
name = "ImageShow"
uuid = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
version = "0.2.3"
version = "0.3.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
MosaicViews = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
FileIO = "1"
ImageCore = "0.8.1"
MosaicViews = "0.2"
OffsetArrays = "0.8, 0.9, 0.10, 0.11, 1"
Reexport = "0.2"
Requires = "0.5.2, 1"
julia = "1"

[extras]
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
PaddedViews = "5432bcbf-9aad-5242-b902-cca2824c8663"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ImageMagick", "PaddedViews", "Test"]
test = ["ImageMagick", "PaddedViews", "ReferenceTests", "Test"]
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,41 @@ graphical platforms such as [IJulia](https://github.com/JuliaLang/IJulia.jl),
It is intended to provide convenient
inline presentation of greyscale or color images.

The intention is that this package will be invisible to most users; it
should typically be invoked by other library packages. Of course, power users
are invited to check out the test suite to see what we think you might do,
and to suggest enhancements.

One user-apparent aspect (for users with good vision) is that large
images are displayed with anti-aliased reduction if the
Large images are displayed with anti-aliased reduction if the
ImageTransformations package is loaded, but with simple down-sampling
otherwise. (ImageTransformations is notably imported by Images, so
`using Images` will provide the nicer display.)

[MosaicViews.jl](https://github.com/JuliaArrays/MosaicViews.jl) is reexported by this
package to provide a handy visualization tool `mosaicview`. It is an enhanced version
of `cat` that "concatenate" images of different sizes and colorants.

```julia
julia> using ImageShow, TestImages

julia> lena = testimage("lena") # 256*256 RGB image

julia> cameraman = testimage("cameraman") # 512*512 Gray image

julia> mosaicview(lena, cameraman; nrow=1)

julia> img = testimage("mri")
3-dimensional AxisArray{ColorTypes.Gray{FixedPointNumbers.Normed{UInt8,8}},3,...} with axes:
:P, 0:1:225
:R, 0:1:185
:S, 0:5:130
And data, a 226×186×27 Array{Gray{N0f8},3} with eltype ColorTypes.Gray{FixedPointNumbers.Normed{UInt8,8}}:

...

julia> mosaicview(img; fillvalue=0.5, npad=2, ncol=7, rowmajor=true)
```

![compare-images](https://user-images.githubusercontent.com/8684355/76654863-f5246100-65a6-11ea-8267-0d6e8c8d3712.png)

![mri-images](https://user-images.githubusercontent.com/8684355/76655141-a4613800-65a7-11ea-8fad-f71748da067b.png)


The functionality of ImageShow has historically been included in the
Images umbrella package.

Expand Down
2 changes: 2 additions & 0 deletions src/ImageShow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module ImageShow
using Requires
using FileIO
using ImageCore, OffsetArrays
using Reexport
@reexport using MosaicViews

const _have_restrict=Ref(false)
function _use_restrict(val::Bool)
Expand Down
81 changes: 81 additions & 0 deletions test/mosaicviews.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@testset "Compat: MosaicViews" begin
# only test image cases

@testset "2D inputs" begin
A1 = fill(Gray(1.), 2, 2)
A2 = fill(RGB(1., 0., 0.), 3, 3)
A3 = fill(RGB(0., 1., 0.), 3, 3)
out = mosaicview(A1, A2, A3) |> collect
@test_reference "references/mosaicviews/2d_opaque_1.png" out by=isequal
out = mosaicview(A1, A2, A3; npad=2, fillvalue=Gray(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/2d_opaque_2.png" out by=isequal
out = mosaicview(A1, A2, A3; npad=2, fillvalue=Gray(0.), nrow=2, rowmajor=true) |> collect
@test_reference "references/mosaicviews/2d_opaque_3.png" out by=isequal

A1 = fill(GrayA(1.), 2, 2)
A2 = fill(RGBA(1., 0., 0.), 3, 3)
A3 = fill(RGBA(0., 1., 0.), 3, 3)
out = mosaicview(A1, A2, A3) |> collect
@test_reference "references/mosaicviews/2d_transparent_1.png" out by=isequal
out = mosaicview(A1, A2, A3; npad=2, fillvalue=GrayA(0., 0.), nrow=2) |> collect
@test_reference "references/mosaicviews/2d_transparent_2.png" out by=isequal
out = mosaicview(A1, A2, A3; npad=2, fillvalue=GrayA(0., 0.), nrow=2, rowmajor=true) |> collect
@test_reference "references/mosaicviews/2d_transparent_3.png" out by=isequal
end

@testset "3D inputs" begin
A = fill(RGB(0., 0., 0.), 2, 2, 3)
A[:, :, 1] .= RGB(1., 0., 0.)
A[:, :, 2] .= RGB(0., 1., 0.)
A[:, :, 3] .= RGB(0., 0., 1.)
out = mosaicview(A) |> collect
@test_reference "references/mosaicviews/3d_opaque_1.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=Gray(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/3d_opaque_2.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=Gray(0.), nrow=2, rowmajor=true) |> collect
@test_reference "references/mosaicviews/3d_opaque_3.png" out by=isequal
out = mosaicview(A, A; npad=2, fillvalue=Gray(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/3d_opaque_4.png" out by=isequal

A = fill(RGBA(0., 0., 0.), 2, 2, 3)
A[:, :, 1] .= RGBA(1., 0., 0.)
A[:, :, 2] .= RGBA(0., 1., 0.)
A[:, :, 3] .= RGBA(0., 0., 1.)
out = mosaicview(A) |> collect
@test_reference "references/mosaicviews/3d_transparent_1.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=GrayA(0., 0.), nrow=2) |> collect
@test_reference "references/mosaicviews/3d_transparent_2.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=GrayA(0.), nrow=2, rowmajor=true) |> collect
@test_reference "references/mosaicviews/3d_transparent_3.png" out by=isequal
out = mosaicview(A, A; npad=2, fillvalue=GrayA(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/3d_transparent_4.png" out by=isequal
end

@testset "4D inputs" begin
A = fill(RGB(0., 0., 0.), 2, 2, 2, 2)
A[1, :, 1, 1] .= RGB(1., 0., 0.)
A[:, :, 1, 2] .= RGB(0., 1., 0.)
A[:, :, 2, 1] .= RGB(0., 0., 1.)
out = mosaicview(A) |> collect
@test_reference "references/mosaicviews/4d_opaque_1.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=Gray(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/4d_opaque_2.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=Gray(0.), nrow=2, rowmajor=true) |> collect
@test_reference "references/mosaicviews/4d_opaque_3.png" out by=isequal
out = mosaicview(A, A; npad=2, fillvalue=Gray(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/4d_opaque_4.png" out by=isequal

A = fill(RGBA(0., 0., 0.), 2, 2, 2, 2)
A[1, :, 1, 1] .= RGBA(1., 0., 0.)
A[:, :, 1, 2] .= RGBA(0., 1., 0.)
A[:, :, 2, 1] .= RGBA(0., 0., 1.)
out = mosaicview(A) |> collect
@test_reference "references/mosaicviews/4d_transparent_1.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=GrayA(0., 0.), nrow=2) |> collect
@test_reference "references/mosaicviews/4d_transparent_2.png" out by=isequal
out = mosaicview(A; npad=2, fillvalue=GrayA(0., 0.), nrow=2, rowmajor=true) |> collect
@test_reference "references/mosaicviews/4d_transparent_3.png" out by=isequal
out = mosaicview(A, A; npad=2, fillvalue=GrayA(0.), nrow=2) |> collect
@test_reference "references/mosaicviews/4d_transparent_4.png" out by=isequal
end
end
Binary file added test/references/mosaicviews/2d_opaque_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/2d_opaque_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/2d_opaque_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/2d_transparent_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/2d_transparent_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/2d_transparent_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_opaque_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_opaque_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_opaque_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_opaque_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_transparent_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_transparent_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_transparent_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/3d_transparent_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_opaque_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_opaque_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_opaque_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_opaque_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_transparent_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_transparent_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_transparent_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/references/mosaicviews/4d_transparent_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Test
using Test, ReferenceTests
using ImageShow, ImageCore, FileIO, OffsetArrays, PaddedViews

@testset "ImageShow" begin
include("writemime.jl")
include("writemime.jl")
include("mosaicviews.jl")
end
4 changes: 0 additions & 4 deletions test/writemime.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using ImageShow, ImageCore, FileIO, OffsetArrays, PaddedViews
# We jump through some hoops so that this test script may work
# whether or not ImageTransformations (a fortiori Images) is loaded.
# See below for details.

# don't import ImageTransformations: restrict

using Test

const workdir = joinpath(tempdir(), "Images")
if !isdir(workdir)
mkdir(workdir)
Expand Down Expand Up @@ -181,5 +178,4 @@ catch
# do nothing
end


nothing