Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8929995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:47:19+00:00 2026-06-15T08:47:19+00:00

I’m testing the implementation of an algorithm calculating the overlap area of two ellipsis.

  • 0

I’m testing the implementation of an algorithm calculating the overlap area of two ellipsis.

The idea of the test is to check visually whether or not the intersection points of the ellipses (if any) are calculated correctly. If this is not the case, then the calculated area cannot be correct.

EDIT: The output of my implementation is a file with the intersection points. I plot the ellipses and the intersection points and savefig them. Visually I check the results and convince myself if the intersection points are correct.

Here is one example:

enter image description here

My problem is simply this visual method doesn’t scale with increasing number of tests (let’s say 1000 cases).

Any ideas how to automate this test?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:47:20+00:00Added an answer on June 15, 2026 at 8:47 am

    Approach

    Decided to post this as another answer since I took a completely fresh approach. I used the Python Imaging Library to draw two ellipses on different images with the colors red and green. I then blended the two images and counted the number of yellow pixels in the image, yellow being the composite of green and red and will become the color of the intersection area. The first ellipse will be colored red, the second green, their intersection yellow. For demonstration purposes I made the second ellipse a circle and made it fully contained in the first so that one could show it’s area should be the area of a circle that size. Because of pixels being counted one won’t get a precise answer but in this example with a resolution of 500×500 the pixel count area was 0.42% from the correct value. Of course if you increase the resolution you can expect to get more precision, but for testing purposes I would just accept a tolerance of +/- 1%. You can comment the lines out that save and show the image I’ve just included them to assist in initial debugging.

    Performance

    I ran a test run of calling the function 1,000 times and it finished in 13.4 seconds. So it takes about 13 milliseconds to create the three images and do a pixel count which isn’t bad performance for the task at hand.

    Code

    from PIL import Image, ImageDraw
    from math import pi
    
    RED, GREEN, YELLOW = (255, 0, 0), (0, 255, 0), (127, 127, 0)
    SIZE = (500, 500)
    
    def overlap(ellipse1, ellipse2):
        im1 = Image.new("RGB", SIZE)
        ImageDraw.Draw(im1).ellipse(ellipse1, fill=RED)
        im2 = Image.new("RGB", SIZE)
        ImageDraw.Draw(im2).ellipse(ellipse2, fill=GREEN)
        im3 = Image.blend(im1, im2, 0.5)
        im3.show()
        im3.save('test.png', "png")
        return [count for count, color in im3.getcolors() if color == YELLOW][0]
    
    area1 = overlap((0, 50, 500, 450), (50, 50, 450, 450))
    area2 = pi * (200**2)
    print "overlap calc:" , area1
    print "exact area:  " , area2
    print "percent diff:" , ((area1 - area2)/area2)*100
    

    Output

    overlap calc: 126196
    exact area:   125663.706144
    percent diff: 0.423585992124
    

    Image

    ellipse with intersection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.