~ubuntu-branches/ubuntu/wily/julia/wily

« back to all changes in this revision

Viewing changes to extras/image.jl

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-02-06 17:54:29 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130206175429-13br5kqpkfjqdmre
Tags: 0.0.0+20130206.git32ff5759-1
* New upstream snapshot.
* debian/copyright: reflect upstream changes
* debian/rules: update get-orig-source to reflect upstream changes
   + Don't ship nginx
   + Adapt for new configure-random target in deps/Makefile
* Enable build of Tk wrapper.
   + debian/control: add build dependency on tk-dev
   + debian/rules: add tk rule to build-arch
* debian/julia.install: install VERSION and COMMIT files
* no-webrepl.patch: new patch
* Refresh other patches
* Add source override for config.status file under deps/random/

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
    sz = size(data)
198
198
    szv = vcat(sz...)
199
199
    n_dims = length(sz)
200
 
    if strlen(arrayi_order) != n_dims
 
200
    if length(arrayi_order) != n_dims
201
201
        error("storage order string must have a length equal to the number of dimensions in the array")
202
202
    end
203
203
    # Enforce uniqueness of each array coordinate name
290
290
    for iarg = 1:2:length(ind)
291
291
        idim = strchr(img.arrayi_order,ind[iarg])
292
292
        if idim == 0
293
 
            error(strcat("Array index name '",ind[iarg],"' does not match any of the names in \"",img.arrayi_order,"\""))
 
293
            error(string("Array index name '",ind[iarg],"' does not match any of the names in \"",img.arrayi_order,"\""))
294
294
        end
295
295
        sniprange[idim] = ind[iarg+1]
296
296
    end
393
393
 
394
394
function lut(pal::Vector, a)
395
395
    out = similar(a, eltype(pal))
396
 
    n = numel(pal)
397
 
    for i=1:numel(a)
 
396
    n = length(pal)
 
397
    for i=1:length(a)
398
398
        out[i] = pal[clamp(a[i], 1, n)]
399
399
    end
400
400
    out
406
406
end
407
407
 
408
408
function indexedcolor(data, pal, w, l)
409
 
    n = numel(pal)-1
 
409
    n = length(pal)-1
410
410
    if n == 0
411
411
        return fill(pal[1], size(data))
412
412
    end
485
485
 
486
486
function imread(file::String)
487
487
    cmd = `convert -format "%w %h" -identify $file rgb:-`
488
 
    stream = fdio(read_from(cmd).fd, true)
 
488
    stream, _ = read_from(cmd)
489
489
    spawn(cmd)
490
490
    szline = readline(stream)
491
491
    spc = strchr(szline, ' ')
644
644
end
645
645
 
646
646
# normalized by Array size
647
 
ssdn{T}(A::Array{T}, B::Array{T}) = ssd(A, B)/numel(A)
 
647
ssdn{T}(A::Array{T}, B::Array{T}) = ssd(A, B)/length(A)
648
648
 
649
649
# sum of absolute differences
650
650
function sad{T}(A::Array{T}, B::Array{T})
652
652
end
653
653
 
654
654
# normalized by Array size
655
 
sadn{T}(A::Array{T}, B::Array{T}) = sad(A, B)/numel(A)
 
655
sadn{T}(A::Array{T}, B::Array{T}) = sad(A, B)/length(A)
656
656
 
657
657
# normalized cross correlation
658
658
function ncc{T}(A::Array{T}, B::Array{T})
710
710
        error("wrong border treatment")
711
711
    end
712
712
    # check if separable
713
 
    U, S, V = svd(filter)
 
713
    U, S, V = svdt(filter)
714
714
    separable = true;
715
715
    for i = 2:length(S)
716
716
        # assumption that <10^-7 \approx 0