Added brick count statistics - #99
Conversation
JuanPotato
left a comment
There was a problem hiding this comment.
2.6 coverage is not a big deal, but if you could fix that, it would be nice. Otherwise just give me back my blank newlines that I hold dear.
| @@ -99,7 +152,6 @@ def legos(): | |||
| """Build flattened lego palettes.""" | |||
| return _flatten_palettes(LEGOS.copy()) | |||
|
|
|||
There was a problem hiding this comment.
I know this is really minor. But why did you delete that line.
| new_frame, brick_stats = make_lego_image(frame, brick_image) | ||
| frames_converted.append(new_frame) | ||
|
|
||
| if stats == True: |
There was a problem hiding this comment.
Protip: instead of if cond == True use if cond
| --palette [all|effects|mono|solid|transparent] | ||
| Palette to use based on real Lego colors. | ||
| --help Show this message and exit. | ||
| --help Show this message and exit.xxsx |
| Palette to use based on real Lego colors. | ||
| --help Show this message and exit. | ||
| --help Show this message and exit.xxsx | ||
| --stats Shows the count of brick colors |
| base_image = apply_thumbnail_effects(base_image, palette, dither) | ||
| make_lego_image(base_image, brick_image).save(output_path) | ||
| lego_image, brick_stats = make_lego_image(base_image, brick_image) | ||
| if stats == True: |
| palette = get_lego_palette(palette_mode) | ||
| base_image = apply_thumbnail_effects(base_image, palette, dither) | ||
| make_lego_image(base_image, brick_image).save(output_path) | ||
| lego_image, brick_stats = make_lego_image(base_image, brick_image) |
There was a problem hiding this comment.
Add newlines to clearly show where if statements end and to improve readability
| lego_image, brick_stats = make_lego_image(base_image, brick_image) | ||
| if stats == True: | ||
| print(brick_stats) | ||
| lego_image.save(output_path) |
|
Really like that you decided to make a pull request to this old project. Been dead for a while. Glad you took some interest to it. |
|
Some of these mistakes were from just last night coding. This was a really fun project and I thought I would contribute to it. |
| for brick_y in range(base_height): | ||
| color = rgb_image.getpixel((brick_x, brick_y)) | ||
|
|
||
| '''Increment color count''' |
There was a problem hiding this comment.
Ok, so im not sure whats going on here completely. But wouldn't this not cover some colors? As in, if some colors in the image aren't in LEGOS_LABEL, it wouldn't count them? Also, why are you doing
if str(palettes.LEGOS_LABEL[color_label]['rgb']) == str(color):
You could just compare the literal r g b values as ints rather than converting to str.
#98 Feature request: displays counts of brick with colors
example:
legofy --stats --palette all image.jpg
{'transparent-flourescent-blue': 426, 'light-stone-grey': 9, 'transparent-green': 4, 'transparent-bluish-violet': 15, 'transparent-light-blue': 10, 'sand-green': 13, 'silver': 5, 'white': 35, 'dark-stone-grey': 6, 'transparent-brown': 6, 'transparent': 62, 'medium-stone-grey': 309}