Skip to content

Commit

Permalink
Upgraded package to work with Julia 0.6 and Images 0.12.
Browse files Browse the repository at this point in the history
* Removed references to image types. Pyramids now works exclusively with arrays.
* Changed all elementwise operations on matrices to use the "dot" form instead. (cos -> cos., etc)
* Upgraded test configuration to use Julia 0.6 in addition to release build.
* Updated REQUIRE to reflect upgrade to Julia 0.6.
* Changed the conversion methods for loading an RGB demo in the frame_interpolation.jl demo to reflect the new way to convert images in Images 0.12.
* Removed references to Image type in the README.md file.
  • Loading branch information
loganwilliams committed Feb 27, 2018
1 parent c474808 commit 2ef607c
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ os:
- osx
julia:
- release
- nightly
- 0.6
notifications:
email: false
# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("Pyramids"); Pkg.test("Pyramids"; coverage=true)'
after_success:
- julia -e 'cd(Pkg.dir("Pyramids")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
- julia -e 'cd(Pkg.dir("Pyramids")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To install and begin using Pyramids, run the following in Julia:

While parts of the Pyramids library are adapted from [matlabPyrTools](http://www.cns.nyu.edu/lcv/software.php), use of the library is quite different. For a more direct port of matlabPyrTools, look at [juliaPyrTools](https://github.com/rcrandall/JuliaPyrTools).

The Pyramids library is used through the `ImagePyramid` class. To create a new `ImagePyramid`, there a several possible constructors. Most typically, they take the form `ImagePyramid(im::Image, t::PyramidType)`.
The Pyramids library is used through the `ImagePyramid` class. To create a new `ImagePyramid`, there a several possible constructors. Most typically, they take the form `ImagePyramid(im::Array, t::PyramidType)`.

Subtypes of `PyramidType` include:
* The abstract type `SimplePyramid`
Expand All @@ -35,11 +35,9 @@ Below is an example of loading an image and converting it to an `ImagePyramid`.

using Images, Pyramids

im = load("test_im.png")
im = real.(load("cameraman.png"))
pyramid = ImagePyramid(im, ComplexSteerablePyramid(), scale=0.75, max_levels=23)

An `ImagePyramid` may also be created directly from an `Array`.

To manipulate an `ImagePyramid`, the `subband` and `update_subband` functions may be used.

hi_residual = subband(pyramid, 0)
Expand Down
8 changes: 4 additions & 4 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.4
Images 0.5
Interpolations 0.3
Colors 0.6
julia 0.6
Images 0.12
Interpolations 0.7
Colors 0.8
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.2-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6.2-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
40 changes: 20 additions & 20 deletions examples/frame_interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function shift_correction(phi_delta::ImagePyramid; shift_limit=0.5)
end
end
else
phi_l[abs(phi_l) .> phi_limit] = 0
phi_l[abs.(phi_l) .> phi_limit] = 0
end

update_subband!(corrected_phase_delta, level, phi_l, orientation=orientation)
Expand Down Expand Up @@ -100,7 +100,7 @@ function blend_and_interpolate(pyramid1::ImagePyramid, pyramid2::ImagePyramid, p

for l = 1:pyramid1.num_levels
for o = 1:pyramid1.num_orientations
new_band = ((1 - alpha) * abs(subband(pyramid1, l, orientation=o)) + alpha * abs(subband(pyramid2, l, orientation=o))) .* exp(complex(0,1) * (angle(subband(pyramid1, l, orientation=o)) + alpha * subband(phase_delta, l, orientation=o)))
new_band = ((1 - alpha) * abs.(subband(pyramid1, l, orientation=o)) + alpha * abs.(subband(pyramid2, l, orientation=o))) .* exp(complex(0,1) * (angle.(subband(pyramid1, l, orientation=o)) + alpha * subband(phase_delta, l, orientation=o)))
update_subband!(blended_pyramid, l, new_band, orientation=o)
end
end
Expand All @@ -122,13 +122,13 @@ end
function phase_difference(pyramid1::ImagePyramid, pyramid2::ImagePyramid)
phase_bands = Dict{Int, Union{Array,Dict{Int, Array}}}()

phase_bands[0] = angle(subband(pyramid2, 0)) - angle(subband(pyramid1, 0))
phase_bands[0] = angle.(subband(pyramid2, 0)) - angle.(subband(pyramid1, 0))

for l = 1:pyramid1.num_levels
this_band = Dict{Int, Array}()

for o = 1:pyramid1.num_orientations
this_band[o] = angle(subband(pyramid2, l, orientation=o)) - angle(subband(pyramid1, l, orientation=o))
this_band[o] = angle.(subband(pyramid2, l, orientation=o)) - angle.(subband(pyramid1, l, orientation=o))
end

phase_bands[l] = copy(this_band)
Expand All @@ -139,17 +139,17 @@ end

println("Loading images")

# convert to LAB, extract the L channel as a 1D array and process it
# update documentation

im1 = load("frame_0.jpg")
im1 = convert(Image{Lab}, float32(im1))
im1 = channelview(Lab.(im1))

im2 = load("frame_1.jpg")
im2 = convert(Image{Lab}, float32(im2))

im1 = convert(Array, separate(im1))
im2 = convert(Array, separate(im2))
im2 = channelview(Lab.(im2))

L1 = im1[:,:,1]
L2 = im2[:,:,1]
L1 = im1[1,:,:]
L2 = im2[1,:,:]

println("Converting images to complex steerable pyramids")

Expand All @@ -166,12 +166,12 @@ for alpha = 0:0.2:1.0
newim = toimage(newpyr)

newLabIm = zeros(im1)
newLabIm[:,:,1] = newim
newLabIm[:,:,2] = (1 - alpha) * im1[:,:,2] + alpha * im2[:,:,2]
newLabIm[:,:,3] = (1 - alpha) * im1[:,:,3] + alpha * im2[:,:,3]

newLabIm = convert(Image, newLabIm)
newLabIm.properties["colorspace"] = "Lab"
newLabIm = convert(Image{RGB}, newLabIm)
save("interpolated_frame_$(alpha).png", newLabIm')
end
newLabIm[1,:,:] = newim
newLabIm[2,:,:] = (1 - alpha) * im1[2,:,:] + alpha * im2[2,:,:]
newLabIm[3,:,:] = (1 - alpha) * im1[3,:,:] + alpha * im2[3,:,:]

newLabIm = colorview(Lab, newLabIm)
rgbIm = RGB.(newLabIm)
save("interpolated_frame_$(alpha).png", rgbIm)
end

Loading

0 comments on commit 2ef607c

Please sign in to comment.