In [23]:
using RODClf, Images

Load test image data


In [24]:
#test image data
imgobj = img_load("test.jpg");
test_image = separate(Image(imgobj.image, imgobj.properties));

Define filter geometry


In [25]:
filter_shape  = FilterGeometry(8, 8, 4, 5, 3, 2, 0, 0);

Define how many segments the 'x' and 'y' axis should be split into


In [26]:
dx_resolution = filter_shape.dx_resolution
dy_resolution = filter_shape.dy_resolution;

Define how many segments are required for both 'x' and 'y' axis


In [27]:
dx_units = filter_shape.dx_units
dy_units = filter_shape.dy_units;

Define number of visible panels on 'x' and 'y' axis; corresponds to lateral and vertical split


In [28]:
x_units = filter_shape.x_units
y_units = filter_shape.y_units;

Create 'dx' and 'dy' values for 'x' and 'y' axis, measured in pixels


In [29]:
dx = signed(imgobj.ndims[1]/dx_resolution-0.5)
dy = signed(imgobj.ndims[2]/dy_resolution-0.5);

Define filter-offset


In [30]:
x_offset = filter_shape.x_offset;
y_offset = filter_shape.y_offset;

Generate filter-coefficients (with offset)

Initialise empty array, 'x', iterate over 'panels' in filter, generating the filter-coefficients for each dimension

In [31]:
x = Array[]
for j in [1:y_units]
    for i in [1:x_units]
        #push!(x, test_image.data[dy*j:dy*dy_units, dx*i:dx*dx_units, :])
        if j == 1
            if i == 1
                push!(x, test_image.data[1*(y_offset+1):((dy*j)-1)*(y_offset+1), 1*(x_offset+1):(dx*i)*(x_offset+1), :])
            else
                push!(x, test_image.data[1*(y_offset+1):((dy*j)-1)*(y_offset+1), (dx*i)*(x_offset+1):((dx*(i+1))-1)*(x_offset+1), :])
                
            end
        else
            if i == 1
                push!(x, test_image.data[(dy*j)*(y_offset+1):(dy*(j+1)-1)*(y_offset+1), 1*(x_offset+1):(dx*i)*(x_offset+1), :])
            else
                push!(x, test_image.data[(dy*j)*(y_offset+1):(dy*(j+1)-1)*(y_offset+1), (dx*i)*(x_offset+1):((dx*(i+1))-1)*(x_offset+1), :])
            end
        end
    end
end

Calculate image integral


In [39]:
function integral_sum2(x)
    tot = 0
    for pt in x
        tot += pt
    end
    print(tot)
end
@time integral_sum2(x[2])


11788.419607842601elapsed time: 0.011266029 seconds (342068 bytes allocated)

In [43]:
@time integral_sum(x[1])


elapsed time: 0.001593079 seconds (238140 bytes allocated)
Out[43]:
12803.627f0

In [16]:
Image(x[1], test_image.properties)


Out[16]:

In [44]:
x_offset = 1
y_offset = 1;

[   (1 * (y_offset+1) * dy) - dy  :     ((dy*1)-1) * (y_offset+1)     ]


Out[44]:
80-element Array{Int32,1}:
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
   ⋮
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160

In [14]:
test_image.properties


Out[14]:
Dict{ASCIIString,Any} with 5 entries:
  "IMcs"         => "sRGB"
  "colorspace"   => "RGB"
  "colordim"     => 3
  "spatialorder" => ASCIIString["y","x"]
  "pixelspacing" => [1,1]