Skip to content

Added brick count statistics - #99

Open
tytoons wants to merge 2 commits into
JuanPotato:masterfrom
tytoons:master
Open

Added brick count statistics#99
tytoons wants to merge 2 commits into
JuanPotato:masterfrom
tytoons:master

Conversation

@tytoons

@tytoons tytoons commented Nov 12, 2017

Copy link
Copy Markdown

#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}

@coveralls

coveralls commented Nov 12, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.0%) to 94.558% when pulling 7a591a1 on tytoons:master into 0154ef5 on JuanPotato:master.

@JuanPotato JuanPotato left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread legofy/palettes.py
@@ -99,7 +152,6 @@ def legos():
"""Build flattened lego palettes."""
return _flatten_palettes(LEGOS.copy())

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is really minor. But why did you delete that line.

Comment thread legofy/__init__.py Outdated
new_frame, brick_stats = make_lego_image(frame, brick_image)
frames_converted.append(new_frame)

if stats == True:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protip: instead of if cond == True use if cond

Comment thread README.md Outdated
--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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit.xxsx What?

Comment thread README.md Outdated
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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

place help at bottom

Comment thread legofy/__init__.py Outdated
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:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if stats

Comment thread legofy/__init__.py
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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newlines to clearly show where if statements end and to improve readability

Comment thread legofy/__init__.py
lego_image, brick_stats = make_lego_image(base_image, brick_image)
if stats == True:
print(brick_stats)
lego_image.save(output_path)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, add a newline

@JuanPotato

Copy link
Copy Markdown
Owner

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.

@coveralls

coveralls commented Nov 12, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.0%) to 94.558% when pulling 5db0a97 on tytoons:master into 0154ef5 on JuanPotato:master.

@tytoons

tytoons commented Nov 12, 2017

Copy link
Copy Markdown
Author

Some of these mistakes were from just last night coding. This was a really fun project and I thought I would contribute to it.

Comment thread legofy/__init__.py
for brick_y in range(base_height):
color = rgb_image.getpixel((brick_x, brick_y))

'''Increment color count'''

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants