Skip to content

Commit

Permalink
Merge pull request #58 from timholy/teh/deprecations
Browse files Browse the repository at this point in the history
Fix 0.4 deprecations. Fixes #57.
  • Loading branch information
timholy committed Dec 18, 2014
2 parents 7991f3a + 011d141 commit a666eed
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Images
Color
Tk
Winston
Compat
1 change: 1 addition & 0 deletions src/ImageView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Color
using Tk
using Cairo
using Images
using Compat

import Base: parent, show, delete!, empty!
import Base.Graphics: width, height, fill, set_coords
Expand Down
2 changes: 1 addition & 1 deletion src/annotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ end
function draw_anchored(ctx::CairoContext, data::AnnotationText, scale_x, scale_y)
set_source(ctx, data.color)
if data.scale && scale_x != 1
fontdesc = fontdescription(data.fontfamily, data.fontoptions, iround(data.fontsize/scale_x))
fontdesc = fontdescription(data.fontfamily, data.fontoptions, round(Int,data.fontsize/scale_x))
else
fontdesc = data.fontdesc
end
Expand Down
5 changes: 3 additions & 2 deletions src/contrast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Tk
using Winston
using Images
import Color.Fractional
using Compat

type ContrastSettings
min
Expand Down Expand Up @@ -48,8 +49,8 @@ function contrastgui{T}(win::Tk.TTk_Container, img::AbstractArray{T}, cs::Contra
pack(fwin, expand=true, fill="both")

dimg = immax-immin
rmin = isa(immin, Fractional) ? immin - dimg/10^4 : ifloor(immin)
rmax = isa(immax, Fractional) ? immax + dimg/10^4 : iceil(immax)
rmin = isa(immin, Fractional) ? immin - dimg/10^4 : floor(Integer, immin)
rmax = isa(immax, Fractional) ? immax + dimg/10^4 : ceil(Integer, immax)
max_slider = Slider(fwin, rmin, rmax)
set_value(max_slider, cs.max)
chist = Canvas(fwin, 2w/3, h)
Expand Down
22 changes: 11 additions & 11 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function ImageSlice2d(img::AbstractArray, props::Dict)
error("Only two or three spatial dimensions are permitted")
end
if !isa(img, AbstractImage)
img = Image(img, ["colordim" => colordim(img), "spatialorder" => spatialorder(img), "colorspace" => colorspace(img)])
img = Image(img, @compat Dict("colordim" => colordim(img), "spatialorder" => spatialorder(img), "colorspace" => colorspace(img)))
end
# Determine how dimensions map to x, y, z, t
xy = get(props, :xy, Images.xy)
Expand Down Expand Up @@ -179,8 +179,8 @@ function _reslice!(img2::ImageSlice2d)
bb = img2.zoombb
xindx = newindexes[img2.xdim]
yindx = newindexes[img2.ydim]
newindexes[img2.xdim] = xindx[max(1,ifloor(bb.xmin)+1):min(length(xindx),iceil(bb.xmax))]
newindexes[img2.ydim] = yindx[max(1,ifloor(bb.ymin)+1):min(length(yindx),iceil(bb.ymax))]
newindexes[img2.xdim] = xindx[max(1,floor(Integer, bb.xmin)+1):min(length(xindx),ceil(Integer, bb.xmax))]
newindexes[img2.ydim] = yindx[max(1,floor(Integer, bb.ymin)+1):min(length(yindx),ceil(Integer, bb.ymax))]
if img2.zdim > 0
newindexes[img2.zdim] = newindexes[img2.zdim][img2.zindex]
end
Expand Down Expand Up @@ -217,8 +217,8 @@ function zoom2!(img2::ImageSlice2d)
end

#
width(img2::ImageSlice2d) = iceil(xmax(img2))-ifloor(xmin(img2))
height(img2::ImageSlice2d) = iceil(ymax(img2))-ifloor(ymin(img2))
width(img2::ImageSlice2d) = ceil(Integer, xmax(img2))-floor(Integer, xmin(img2))
height(img2::ImageSlice2d) = ceil(Integer, ymax(img2))-floor(Integer, ymin(img2))
xmin(img2::ImageSlice2d) = xmin(img2.zoombb)
xmax(img2::ImageSlice2d) = xmax(img2.zoombb)
ymin(img2::ImageSlice2d) = ymin(img2.zoombb)
Expand All @@ -241,7 +241,7 @@ yrange(img2::ImageSlice2d) = (ymin(img2), ymax(img2))
function view{A<:AbstractArray}(img::A; proplist...)
# Convert keyword list to dictionary
props = Dict{Symbol,Any}()
sizehint(props, length(proplist))
sizehint!(props, length(proplist))
for (k,v) in proplist
props[k] = v
end
Expand Down Expand Up @@ -352,7 +352,7 @@ end
function view{A<:AbstractArray}(imgc::ImageCanvas, img::A; interactive=true, proplist...)
# Convert keyword list to dictionary
props = Dict{Symbol,Any}()
sizehint(props, length(proplist))
sizehint!(props, length(proplist))
for (k,v) in proplist
props[k] = v
end
Expand All @@ -372,7 +372,7 @@ end
function view{A<:AbstractArray}(c::Canvas, img::A; interactive=true, proplist...)
# Convert keyword list to dictionary
props = Dict{Symbol,Any}()
sizehint(props, length(proplist))
sizehint!(props, length(proplist))
for (k,v) in proplist
props[k] = v
end
Expand Down Expand Up @@ -536,7 +536,7 @@ end
function updatexylabel(xypos, imgc, img2, x, y)
xu,yu = device_to_user(getgc(imgc.c), x, y)
# Image-coordinates
xi,yi = ifloor(1+xu), ifloor(1+yu)
xi,yi = floor(Integer, 1+xu), floor(Integer, 1+yu)
if isinside(imgc.canvasbb, x, y)
val = img2[xi,yi]
set_value(xypos, "$xi, $yi: $val")
Expand Down Expand Up @@ -725,9 +725,9 @@ function rendersize(w::Integer, h::Integer, r)
wh = h
if !is(r, nothing)
if r > 1
ww = iround(w*r)
ww = round(Integer, w*r)
else
wh = iround(h/r)
wh = round(Integer, h/r)
end
end
ww, wh
Expand Down
4 changes: 2 additions & 2 deletions src/navigation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Navigation

using Tk
using Tk, Compat

## Type for holding GUI state
# This specifies a particular 2d slice from a possibly-4D image
Expand Down Expand Up @@ -159,7 +159,7 @@ function arrowheads(sz, vert::Bool)
end

function icondata(iconsize, frac)
center = iceil(iconsize[1]/2)
center = ceil(Integer, iconsize[1]/2)
data = Bool[ 2abs(i-center)< iconsize[2]-(j-1)/frac for i = 1:iconsize[1], j = 1:iconsize[2] ]
data .== true
end
Expand Down
6 changes: 3 additions & 3 deletions test/test4d.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Images
using Compat

# Create a cone in 3d that changes color over time
sz = [201, 301, 31]
center = iceil(sz/2)
center = [(s+1)>>1 for s in sz] # ceil(Int, sz/2)
C3 = Bool[(i-center[1])^2+(j-center[2])^2 <= k^2 for i = 1:sz[1], j = 1:sz[2], k = sz[3]:-1:1]
cmap1 = uint32(linspace(0,255,60))
cmap = Array(Uint32, length(cmap1))
Expand All @@ -13,5 +14,4 @@ C4 = Array(Uint32, sz..., length(cmap))
for i = 1:length(cmap)
C4[:,:,:,i] = C3*cmap[i]
end
img = Images.Image(C4, ["spatialorder" => ["x", "y", "z"], "timedim" => 4, "colorspace" => "RGB24", "pixelspacing" => [1,1,3]])

img = Images.Image(C4, @compat Dict("spatialorder" => ["x", "y", "z"], "timedim" => 4, "colorspace" => "RGB24", "pixelspacing" => [1,1,3]))

0 comments on commit a666eed

Please sign in to comment.