Home > Software design >  Measure and label length on an image
Measure and label length on an image

Time:10-18

I am looking for the easiest way to draw a solid line on a picture and display the length of the line drawn. Attached a picture. Any idea to do it under win7? Thank you

Example

CodePudding user response:

Easiest is to go to ImageJ in your browser, and click:

File -> Open Sample -> Cardio

Then click Line Tool and draw your line. It'll tell you the length in the info window.

You could equally install it locally, but that would be harder.

You could just as easily use Photopea.

CodePudding user response:

To draw a line coordinates are needed. So then it's possible to calculate the length of the line from equation: length = sqrt((Xend - Xstart)^2 (Yend - Ystart)^2 ). And according to that example mentioned in question: You can make a loop for every row to store the value of first coloured pixel and last coloured pixel, calculate the length between them and compare the result with the next row. In auxiliary variable may be stored the maximal result (actualization after every row calculation)

// C   Implementation for drawing line
#include <graphics.h>
  
// driver code
int main()
{
    // gm is Graphics mode which is a computer display
    // mode that generates image using pixels.
    // DETECT is a macro defined in "graphics.h" header file
    int gd = DETECT, gm;
  
    // initgraph initializes the graphics system
    // by loading a graphics driver from disk
    initgraph(&gd, &gm, "");
  
    // line for x1, y1, x2, y2
    line(150, 150, 450, 150);
  
    // line for x1, y1, x2, y2
    line(150, 200, 450, 200);
  
    // line for x1, y1, x2, y2
    line(150, 250, 450, 250);
  
    getch();
  
    // closegraph function closes the graphics
    // mode and deallocates all memory allocated
    // by graphics system .
    closegraph();
}

You can use C for example CodeBlocks. But to start the best would be Processing https://processing.org/reference/line_.html

  • Related