I have a camera taking a picture of a rubik's cube and I want to be able to see what color each cuboid is. I am currently using the HSV color space and, in theory, this would help differentiate colors. In practice, however, the light variations on each cuboid make it almost impossible to get the right ranges of HSV values to get the correct color. I have a series of if statments that almost works, but only has a 25% accuracy because of light changes. Any ideas on how to possible edit the image to remove all brightness variation and have just the exposed colors?
#๐ How do I find the specific color of an image while accounting for light variations?
34 messages ยท Page 1 of 1 (latest)
@dawn echo
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
Can you post an example problematic image + code?
To the human eye, the image is quite discernable. But to HSV value, the hues frequently overlap and some cuboids are seen as two. Thus, the really poorly coded if statements that check a variety of hue, satuaration, and value values
I realized that doing those complex if statments wouldn't be the best solution lol
...uh, it feels barely discernible to me with those lightning conditions and reflections
I have some lights that can light up the cube but it just makes the problem worse
like the bottom cuboids just shine white lol
doing manually just to see if I even got the colors right?
so are there any color filters or anything that will get just the colors?
correct for all of them but the first green one. that one is white p-p
i might add a light at the top (that side), however i feel like, again, it'll just make the colors look completely white
well I think I may have found a solution: taking higher quality images lol
new image, i'll try with this
much better
I'm trying some things, and got this with the previous image so far
with the new cube ; feels like it just might work?
yeah that definitely looks way better. How exactly did you do that?
Would it be possible to adjust the white balance of whatever is taking that picture to make it a little bit less... green? That would probably (I don't actually know it would be, theoretically it would just shift the color ranges you are looking for) make it easier to distinguish colors (especially different shades of white and green)
e.g.:
I don't actually know how you would do that using python though, sorry. ๐
actually, I can!
lemme see if it works though
current progress: https://paste.pythondiscord.com/F4IA
these are all the white balance options
unfortunately none of them look like the one u sent @merry tendon
thanks, let me check this out
I mean I cheated and just used photoshop... this is still much better that your original picture imo
maybe there is a way to take image color histogram and up contrast to fit known present colors?
tried just ```py
expected_white = np.array(decompose(0xbcfbb7))
arr = arr * (255 / expected_white)[None, None, :]
arr = np.minimum(arr, 255)
Yeah idk, dropping out of this one - good luck
if you haven't yet, remember to look up which methods researchers use for that, solving a rubics cube with robotics is a relatively common research problem iirc?
idea reminds me of this
https://github.com/ajegorovs/aj_python_tool_lib/blob/main/data_processing/image_processing/Quantization_implementation.ipynb
where you seed initial guess for all colors of a cube
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.