-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed possible color collisions in the generated colormap #4007
Conversation
Co-authored-by: dvkruchinin <[email protected]>
sorted_colors = sorted(used_colors) | ||
max_dist = max(zip(sorted_colors, sorted_colors[1:]), key=lambda c_pair: c_pair[1][0] - c_pair[0][0]) | ||
|
||
return ((max_dist[0][0] + max_dist[1][0]) // 2, max_dist[0][1], max_dist[0][2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @azhavoro, Is it the final version of this patch? If it is, then I have a question:
Will this solution work correctly if all used colors have a same R-value? For example in case:
used_colors = [(100, 0, 0), (100, 50, 0), (100, 0, 50)]
this code will return (100, 0, 0)
but this color is already use. I'm not sure that such situation is very likely, but it seems to me that we can extend this algorithm to other components of the color as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, fixed.
if color is None: | ||
color = get_color_from_index(DEFAULT_COLORMAP_CAPACITY + offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this const is not used, so should be deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dvkruchinin Hi, could you prepare a test for this case? |
Hi, sure. A test will be prepared. |
Motivation and context
How has this been tested?
Checklist
develop
branchcvat-core, cvat-data and cvat-ui)
License
Feel free to contact the maintainers if that's a concern.