In [2]:
using RODClf, Images

Load test image data


In [3]:
#test image data
imgobj = img_load("test.jpg");
test_image = separate(Image(imgobj.image, imgobj.properties));
Initialise empty array, 'x', iterate over 'panels' in filter, generating the filter-coefficients for each dimension

In [4]:
filter_shape  = FilterGeometry(8, 8, 4, 5, 3, 2, 0, 0);
dx_resolution = filter_shape.dx_resolution
dy_resolution = filter_shape.dy_resolution;
dx_units = filter_shape.dx_units
dy_units = filter_shape.dy_units;
x_units = filter_shape.x_units
y_units = filter_shape.y_units;
dx = signed(imgobj.ndims[1]/dx_resolution-0.5)
dy = signed(imgobj.ndims[2]/dy_resolution-0.5);
x_offset = filter_shape.x_offset;
y_offset = filter_shape.y_offset;

x = Array[]
for j in [1:y_units]
    for i in [1:x_units]
        if j == 1
            if i == 1
                push!(x, test_image.data[1*(y_offset+1):((dy*j)-1)*(y_offset+1)+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)+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

In [5]:
Image(x[2], test_image.properties)
#size(x[1])


Out[5]:

In [374]:
x_offset = 2
y_offset = 1
j = 1
i = 2
#y_test = [(1*(y_offset+1)*dy)-dy+1:((dy*j)-1)*(y_offset+1)+(1+y_offset)]
#x_test = [(1*(x_offset+1)*dx)-dx+1:((dx*i)-1)*(x_offset+1)+(1+x_offset)]

#y_not0_test = [(dy*j)*(y_offset+1)+1:(((dy*(j+1))-1)*((y_offset+1)))-dy+(1+y_offset)]
#x_not0_test = [(dx*i)*(x_offset+1)+1:(((dx*(i+1))-1)*((x_offset+1)))-dx+(1+x_offset)]
#x_not0_test = [((dx*i+dx)-dx)+1:(((dx*(i+1))-1)*((x_offset+1)))-dx+(1+x_offset)]


Out[374]:
2

In [449]:
(x_offset+1)


Out[449]:
1

In [469]:
filter_shape  = FilterGeometry(8, 8, 4, 5, 3, 2, 0, 0);
dx_resolution = filter_shape.dx_resolution
dy_resolution = filter_shape.dy_resolution;
dx_units = filter_shape.dx_units
dy_units = filter_shape.dy_units;
x_units = filter_shape.x_units
y_units = filter_shape.y_units;
dx = signed(imgobj.ndims[1]/dx_resolution-0.5)
dy = signed(imgobj.ndims[2]/dy_resolution-0.5);
x_offset = filter_shape.x_offset;
y_offset = filter_shape.y_offset;

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

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


Out[14]:
81x62x3 Array{UfixedBase{Uint8,8},3}:
[:, :, 1] =
 0.882  0.882  0.886  0.898  0.898  …  0.867  0.851  0.851  0.851  0.859
 0.89   0.894  0.886  0.878  0.91      0.847  0.863  0.898  0.855  0.855
 0.918  0.894  0.882  0.882  0.906     0.867  0.867  0.922  0.878  0.867
 0.878  0.878  0.859  0.863  0.875     0.859  0.902  0.914  0.867  0.827
 0.918  0.878  0.902  0.906  0.871     0.875  0.886  0.886  0.878  0.855
 0.902  0.902  0.918  0.867  0.875  …  0.878  0.859  0.878  0.859  0.843
 0.867  0.875  0.918  0.878  0.855     0.871  0.859  0.882  0.871  0.875
 0.882  0.863  0.89   0.918  0.898     0.898  0.863  0.863  0.867  0.878
 0.91   0.882  0.906  0.882  0.863     0.827  0.871  0.863  0.898  0.925
 0.91   0.898  0.906  0.894  0.89      0.839  0.863  0.875  0.871  0.878
 0.886  0.914  0.906  0.91   0.922  …  0.839  0.882  0.89   0.902  0.875
 0.886  0.886  0.89   0.898  0.925     0.875  0.839  0.882  0.859  0.89 
 0.878  0.875  0.914  0.898  0.886     0.863  0.894  0.875  0.843  0.914
 ⋮                                  ⋱                       ⋮           
 0.855  0.902  0.91   0.922  0.902     0.953  0.973  0.949  0.945  0.933
 0.875  0.933  0.875  0.863  0.902  …  0.969  0.957  0.945  0.965  0.941
 0.89   0.918  0.906  0.886  0.898     0.941  0.953  0.965  0.961  0.98 
 0.902  0.882  0.882  0.878  0.894     0.98   0.957  0.961  0.957  0.937
 0.898  0.91   0.91   0.886  0.882     0.941  0.969  0.949  0.957  0.949
 0.906  0.918  0.914  0.894  0.902     0.945  0.969  0.965  0.973  0.961
 0.898  0.894  0.894  0.882  0.914  …  0.957  0.953  0.961  0.957  0.953
 0.878  0.914  0.929  0.918  0.922     0.957  0.953  0.953  0.937  0.957
 0.89   0.918  0.918  0.922  0.906     0.965  0.945  0.961  0.949  0.961
 0.925  0.914  0.894  0.906  0.914     0.957  0.937  0.949  0.961  0.961
 0.918  0.898  0.91   0.902  0.925     0.941  0.961  0.925  0.961  0.976
 0.937  0.922  0.894  0.922  0.894  …  0.918  0.965  0.961  0.957  0.949

[:, :, 2] =
 0.91   0.918  0.922  0.918  0.906  …  0.898  0.89   0.91   0.918  0.902
 0.925  0.937  0.929  0.906  0.918     0.882  0.89   0.929  0.906  0.91 
 0.953  0.941  0.925  0.918  0.925     0.914  0.886  0.929  0.902  0.925
 0.91   0.914  0.902  0.906  0.902     0.91   0.922  0.918  0.898  0.902
 0.929  0.898  0.929  0.937  0.902     0.91   0.922  0.91   0.929  0.929
 0.914  0.914  0.933  0.894  0.91   …  0.906  0.902  0.929  0.918  0.898
 0.882  0.89   0.933  0.898  0.886     0.902  0.906  0.945  0.922  0.898
 0.906  0.886  0.91   0.933  0.922     0.933  0.91   0.925  0.906  0.886
 0.925  0.894  0.925  0.898  0.878     0.867  0.91   0.91   0.925  0.941
 0.929  0.918  0.922  0.91   0.902     0.894  0.91   0.886  0.875  0.914
 0.918  0.933  0.922  0.918  0.929  …  0.906  0.933  0.906  0.914  0.91 
 0.925  0.918  0.906  0.906  0.933     0.925  0.898  0.953  0.918  0.922
 0.918  0.906  0.933  0.918  0.898     0.902  0.941  0.945  0.914  0.961
 ⋮                                  ⋱                       ⋮           
 0.89   0.914  0.925  0.937  0.914     0.961  0.98   0.957  0.953  0.941
 0.914  0.945  0.902  0.91   0.922  …  0.984  0.973  0.953  0.973  0.949
 0.91   0.925  0.941  0.941  0.929     0.976  0.973  0.98   0.969  0.988
 0.898  0.894  0.922  0.925  0.925     0.996  0.969  0.973  0.965  0.941
 0.902  0.929  0.945  0.925  0.914     0.957  0.984  0.965  0.973  0.965
 0.914  0.933  0.945  0.925  0.933     0.961  0.98   0.976  0.988  0.976
 0.914  0.91   0.925  0.914  0.945  …  0.973  0.965  0.973  0.969  0.973
 0.906  0.933  0.949  0.937  0.953     0.969  0.969  0.973  0.953  0.976
 0.91   0.937  0.933  0.941  0.937     0.976  0.961  0.976  0.965  0.973
 0.945  0.925  0.906  0.925  0.953     0.973  0.949  0.961  0.973  0.973
 0.929  0.91   0.922  0.922  0.961     0.953  0.973  0.941  0.976  0.988
 0.953  0.941  0.925  0.957  0.945  …  0.937  0.98   0.976  0.973  0.965

[:, :, 3] =
 0.847  0.851  0.847  0.839  0.824  …  0.816  0.796  0.835  0.855  0.835
 0.851  0.871  0.863  0.835  0.835     0.816  0.82   0.871  0.839  0.82 
 0.871  0.863  0.859  0.851  0.847     0.82   0.8    0.875  0.847  0.843
 0.82   0.839  0.839  0.843  0.839     0.808  0.835  0.863  0.839  0.827
 0.847  0.82   0.867  0.878  0.843     0.843  0.855  0.855  0.863  0.851
 0.839  0.847  0.875  0.831  0.843  …  0.835  0.835  0.859  0.843  0.839
 0.824  0.831  0.867  0.82   0.796     0.812  0.82   0.843  0.843  0.851
 0.859  0.831  0.831  0.843  0.812     0.859  0.831  0.824  0.812  0.831
 0.835  0.812  0.847  0.831  0.812     0.769  0.816  0.824  0.855  0.875
 0.843  0.839  0.855  0.851  0.835     0.804  0.824  0.82   0.812  0.831
 0.827  0.855  0.855  0.863  0.875  …  0.831  0.863  0.839  0.847  0.827
 0.827  0.827  0.839  0.851  0.878     0.847  0.816  0.859  0.827  0.831
 0.82   0.816  0.855  0.839  0.824     0.808  0.847  0.843  0.812  0.867
 ⋮                                  ⋱                       ⋮           
 0.808  0.847  0.867  0.878  0.847     0.875  0.894  0.875  0.871  0.859
 0.82   0.871  0.831  0.831  0.843  …  0.894  0.882  0.867  0.886  0.867
 0.824  0.843  0.859  0.851  0.839     0.871  0.882  0.89   0.882  0.902
 0.82   0.812  0.827  0.831  0.835     0.906  0.886  0.906  0.91   0.871
 0.831  0.851  0.863  0.831  0.824     0.867  0.894  0.875  0.882  0.875
 0.859  0.867  0.863  0.835  0.843     0.863  0.906  0.902  0.898  0.886
 0.855  0.843  0.843  0.824  0.855  …  0.875  0.882  0.898  0.886  0.886
 0.835  0.855  0.863  0.847  0.859     0.886  0.863  0.855  0.847  0.89 
 0.831  0.851  0.843  0.851  0.843     0.894  0.855  0.871  0.875  0.89 
 0.859  0.843  0.824  0.839  0.859     0.882  0.867  0.878  0.898  0.89 
 0.847  0.827  0.847  0.843  0.878     0.871  0.89   0.851  0.871  0.882
 0.863  0.855  0.843  0.875  0.867  …  0.851  0.89   0.886  0.875  0.867

In [372]:
((dx*i+dx)-dx)+1


Out[372]:
125

In [528]:
x_offset = 2
y_offset = 1
j = 1
i = 2
#y_test = [(1*(y_offset+1)*dy)-dy+1:((dy*j)-1)*(y_offset+1)+(1+y_offset)]
#x_test = [(1*(x_offset+1)*dx)-dx+1:((dx*i)-1)*(x_offset+1)+(1+x_offset)]

#y_not0_test = [(dy*j)*(y_offset+1)+1:(((dy*(j+1))-1)*((y_offset+1)))-dy+(1+y_offset)]
#x_not0_test = [(dx*i)*(x_offset+1)+1:(((dx*(i+1))-1)*((x_offset+1)))-dx+(1+x_offset)]
#x_not0_test = [((dx*i+dx)-dx)+1:(((dx*(i+1))-1)*((x_offset+1)))-dx+(1+x_offset)]dx*1+1
((dx*i)+1)


Out[528]:
125

In [527]:
(x_offset+1)*(dx*i)-(i*dx)+1+(x_offset)-1: (x_offset+1)*(dx*i)-(i*dx)+(dx+1)-1


Out[527]:
374:434

In [521]:
1:62, 62:124, 125:186


Out[521]:
(1:62,62:124,125:186)

In [520]:
125+dx


Out[520]:
187

In [ ]: