I'm trying to use a2d mask as a partial reference to a 4d, like so....
glcm[i, j, mask] = 1
mask is a 512x512 Boolean Array. But it gives the error....
BoundsError: attempt to access 8×8×512×512 Array{UInt8, 4} at index [1, 1, 512×512 BitMatrix]
So I tried it with a toy example.....
begin
levels = 8
h , w = 6, 6
glcm = zeros(UInt8, (levels, levels, h, w))
a = I(6) .== 1
glcm[1, 1, a] .= 1
end
and i don't get an error..... what am I missing here?
In the first example, you forgot the dot before the equal sign in the assignment
Thanks for catching that.... but it apparently wasn't the (only) problem... still coming up with BoundsError before it even gets to assignment....
I don't think you can do partial Boolean indexing in general. It seems like your toy example works thanks to peculiarities of the Diagonal
type. For a workaround, you could try @view(glcm[i, j, :, :])[mask] .= 1
.
Last updated: Nov 22 2024 at 04:41 UTC