- Joined
- Apr 7, 2022
- Messages
- 14
- Reaction score
- 0
Hi Guys,
Below is some excel VBA code that shows what I am trying to do in Python.
I am trying to make an array in python that gives a 3 dimensional matrix that shows every combination of 1 to 26 in all 3 dimensions.
below is my attempt of the code:
The resulting array should have an X,Y,Z columns with 19683 rows = (26+1)^3.
My code gives the correct shape array, 3 columns and 19683 rows but the array is full of zeros, the array should look something like the following:
Thanks!
Edit/Additional Context:
I am trying to create an array for R,G,B colours (Red, Green, Blue which each vary from 0 to 255). I want to take a photo, and have that photo measure pixel colours by categorizing them into groups/"buckets". whichever "bucket" has the greatest number of occurrences, means the colour is mostly that value, which is a variable for other code.
Below is some excel VBA code that shows what I am trying to do in Python.
Code:
Sub test()
i = 1
For x = 0 To 26
For y = 0 To 26
For Z = 0 To 26
Cells(i, 1) = x
Cells(i, 2) = y
Cells(i, 3) = Z
i = i + 1
Next Z
Next y
Next x
End Sub
I am trying to make an array in python that gives a 3 dimensional matrix that shows every combination of 1 to 26 in all 3 dimensions.
below is my attempt of the code:
Python:
ColourBlockSize = 10 #(x,x,x) sized blocks to split the 255 R-G-B colours for finding the Mode (most common colour)
NumberofColourBlocks = math.ceil(255/ColourBlockSize) #number of ColourBlocks in one dimension
num01 = int(math.pow(NumberofColourBlocks+1,3))
ColourBlockArray = np.empty([NumberofColourBlocks+1,NumberofColourBlocks+1,NumberofColourBlocks+1], dtype=np.int)
The resulting array should have an X,Y,Z columns with 19683 rows = (26+1)^3.
My code gives the correct shape array, 3 columns and 19683 rows but the array is full of zeros, the array should look something like the following:
Thanks!
Edit/Additional Context:
I am trying to create an array for R,G,B colours (Red, Green, Blue which each vary from 0 to 255). I want to take a photo, and have that photo measure pixel colours by categorizing them into groups/"buckets". whichever "bucket" has the greatest number of occurrences, means the colour is mostly that value, which is a variable for other code.
Last edited: