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

Better Visualization Functions #129

Merged
merged 4 commits into from
Apr 3, 2022
Merged

Better Visualization Functions #129

merged 4 commits into from
Apr 3, 2022

Conversation

lolipopshock
Copy link
Member

@lolipopshock lolipopshock commented Apr 3, 2022

  1. Not drawing the box outlines when setting box_width=0. For example,

    from PIL import Image
    import layoutparser as lp
    
    image = Image.new('RGB', (50,50), color='white')
    lp.draw_box(image, [lp.Rectangle(10, 10, 40, 40)], box_width=0)

    Previously, it will draw a box image.

  2. Allowing setting box_color in draw_box:

    1. directly setting box_color:

      from PIL import Image
      import layoutparser as lp
      
      image = Image.new('RGB', (50,50), color='white')
      
      lp.draw_box(image, 
                  [lp.TextBlock(lp.Rectangle(10, 10, 20, 20), type='a'), 
                  lp.TextBlock(lp.Rectangle(30, 30, 45, 45), type='b'),] ,
                  box_color=['black', 'red'])

      image

    2. overriding color_map:

      lp.draw_box(image, 
                  [lp.TextBlock(lp.Rectangle(10, 10, 20, 20), type='a'), 
                  lp.TextBlock(lp.Rectangle(30, 30, 45, 45), type='b'),] ,
                  color_map={'a':'black', 'b':'blue'}, box_color=['black', 'red'])

      image

  3. Setting box_color, box_alpha, and box_width for each objects:

    from PIL import Image
    import layoutparser as lp
    
    image = Image.new('RGB', (50,50), color='white')
    lp.draw_box(image, 
                [lp.TextBlock(lp.Rectangle(10, 10, 20, 20), type='a'), 
                lp.TextBlock(lp.Rectangle(30, 30, 45, 45), type='b'),] ,
                box_color=['black', 'red'], 
                box_alpha=[0.1, 0.5], 
                box_width=[2,4])

    image

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.

None yet

1 participant