I am not able to run your code because of some scoping issues (qfunc
accesses the global variable A, that you did not provide the definition
for), but I would expect the line
value = A[col/scale_x, row/scale_y]
to cause InexactError() if col/scale_x does not have a integer value. If
you want truncated integer division, you must use the div(col, scale_x)
function.
Ivar
kl. 06:39:38 UTC+1 tirsdag 18. mars 2014 skrev Siddha Ganju følgende:
>
> I am getting Inexact Error in qfunc, where I am applying the Nearest
> Neighbor to the input image array.
>
> julia> qfunc()
> ERROR: InexactError()
> in getindex at array.jl:289
> in qfunc at none:2
>
>
> function qfunc()
> value = A[col/scale_x, row/scale_y]
> new_image_data[col,row,value] = A[col,row]
> end
>
> This is being called in the rescale function as:
>
> function rescale(scale_x,scale_y)
> img = imread("index.png")
> h = height(img)
> w = width(img)
> new_h = int(h*scale_y)
> new_w = int(w*scale_x)
> A = data(img)
> for col=1:new_w
> for row=1:new_h
> qfunc()
> end
> end
> new_image = InterpGrid(new_image_data, BCnil, InterpGrid)
>
> After going through the threads on this group, I found that Inexact error
> is usually when matrix multiplication/division is going wrong. So I may
> probably be wrong in the way I am indexing the two arrays. Please suggest
> what should I change.
>