Inexact Error is being triggered because you're trying to index a _regular_
array with a fractional value, e.g., A[3.2, 7.43].
Comments:
- pass your image in as an argument to the rescale function, don't load it
from disk within the function. See many examples in Images.
- right after you define A, define Ai using InterpGrid
- then allocate the array for the new image and fill it with values using
Ai[i1/scale1, i2/scale2].
- Get rid of qfunc altogether---that was there in the example in Grid.jl
simply to generate comparison data.
--Tim
On Monday, March 17, 2014 10:39:38 PM Siddha Ganju wrote:
> 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.