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

  • SEARCH
  • Home
  • 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 7628449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:35:45+00:00 2026-05-31T05:35:45+00:00

Turns out I am not explaining what I want to do very well so

  • 0

Turns out I am not explaining what I want to do very well so I am going to re-write the whole question again and add graphics to assist in the explanation.

I am designing an app for android/iPhone. I have designed one algorithm for it already, but am stuck on the next one. What I am aiming to do is place two horizontal lines on an image (any image, just a picture taken by the iPhone/android) and then calculate what pixel the lines lye on, to then calculate the number of pixels between them.
I.e.
Take this image:

https://i.stack.imgur.com/41vS1.png

Then place two horizontal lines anywhere on the image, like so:

https://i.stack.imgur.com/ne4tV.png

What I want to calculate is the value of y, or how many vertical pixels are between the two lines. To do this I must know what pixel the two lines lye on.
Assuming that the horizontal lines are both only 1 pixel in height what would I use to work out what pixel in the image the line lies on. I.e. what is the value of the y-intercept(y=mx+c), or c, on each of the horizontal lines.
To explain what I mean further, lets assume that an image is a graph. Each pixel equals a value of 1, so for an image with a resolution of 1920×2560 the maximum value of the y-axis would be 1920 and the maximum of the x-axis would be 2560. How would I design an algorithm to calculate what the y-intercept of both lines are?

  • 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-05-31T05:35:46+00:00Added an answer on May 31, 2026 at 5:35 am

    Distance between two points (Pythagora):

    dx = x1 - x2;
    dy = y1 - y2;
    
    dist = sqrt (dx*dx + dy*dy);
    

    Distance between two horizontal lines:

    d = y1 - y2;
    

    If your lines are defined as y1 = k1x + n1 and y2 = k2x + n2, then (they’re horizontal, k1 and k2 are 0) the distance between them is n2 - n1.

    EDIT: ok, after you edited your question it makes a bit more sense now. But still: since you (or user) is adding the lines, your code always knows where they lie. Their end coordinates would be:

    line1: {(0,y1):(picture.width,y1)}
    line2: {(0,y2):(picture.width,y2)}
    distance: |y2-y1|

    Since they’re both horizontal they ofcourse never cross.

    You should just keep a reference to y1 and y2 (from the line-placing code) in an appropriate space. Since your question is for Android and iOS the answer is: in that part of code that would correspond to model in MVC.

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

Sidebar

Related Questions

EDIT: It turns out I am not very intelligent. I should have checked first
I thought this would be fairly simple but it turns out not to work
EDIT: solved it, turns out I should use %c not %s because foodSelect and
It turns out that iptables doesn't handle leading zeros too well. As $machinenumber that
Edit: It turns out I missed something obvious, but I'm going to leave the
EDIT: it turns out it's NOT a problem.. pfew! phpMOadmin is not able to
SOLVED : Turns out the people not being able to access TFS via VS2010
Possible Duplicate: Division in C++ not working as expected Turns out my program has
I need to use an unsigned double but it turns out C# does not
Simple enough, it would seem, but it turns out not to be - mainly

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.