Skip to content
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

Added brick count statistics #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

tytoons
Copy link

@tytoons tytoons commented Nov 12, 2017

#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
Copy link

coveralls commented Nov 12, 2017

Coverage Status

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

Copy link
Owner

@JuanPotato JuanPotato left a comment

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.

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

Copy link
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.

frames_converted.append(new_frame)

if stats == True:
Copy link
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

README.md Outdated
@@ -43,7 +43,8 @@ Options:
--dither / --no-dither Use dither algorithm to spread the color approximation error.
--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
Owner

Choose a reason for hiding this comment

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

edit.xxsx What?

README.md Outdated
@@ -43,7 +43,8 @@ Options:
--dither / --no-dither Use dither algorithm to spread the color approximation error.
--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
--stats Shows the count of brick colors
Copy link
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

'''Legofy an image'''
new_size = get_new_size(base_image, brick_image, size)
base_image.thumbnail(new_size, Image.ANTIALIAS)
if palette_mode:
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)
if stats == True:
Copy link
Owner

Choose a reason for hiding this comment

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

if stats

'''Legofy an image'''
new_size = get_new_size(base_image, brick_image, size)
base_image.thumbnail(new_size, Image.ANTIALIAS)
if palette_mode:
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
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

lego_image, brick_stats = make_lego_image(base_image, brick_image)
if stats == True:
print(brick_stats)
lego_image.save(output_path)
Copy link
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
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
Copy link

coveralls commented Nov 12, 2017

Coverage Status

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

@tytoons
Copy link
Author

tytoons commented Nov 12, 2017

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_x in range(base_width):
for brick_y in range(base_height):
color = rgb_image.getpixel((brick_x, brick_y))

'''Increment color count'''
Copy link
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