A main idea mathematicians use to define lengths of curves, areas of flat shapes, volumes of solids etc is to divide them into smaller and smaller parts such that
- The finer and finer subdivisions approximate the shape better and better.
- The measure of the small parts is already defined.
However, one needs to be careful that this approach creates a definition that is unique and that the resulting definition agrees with what we expect in cases where we can define the measure in a different way or measure them on physical objects.
Your example of computer graphics using a grid of pixels to approximate shapes is both an illustration of this method and also an illustration of some of the difficulties.
Example 1: Measuring the area of a disc
Subdividing a circular disc into squares and adding up the areas of the squares will give a good approximation of the area of the circle, when the squares are small enough.
Example 2: Measuring the circumference of a circle
If you just count the number of squares on the perimeter of the disc to get an approximation of the length of the circumference, you can get a wrong result.
Somehow the result is too short, and it would remain too short even if the subdivision was made finer and finer.
The method could be improved, for example by noting that some of the pixels are only connected at a corner and thus their centers are further away than the side length of the square.
But I expect it to be difficult to describe mathematically the location of all the pixels on the circumference in a finer and finer grid.
Example 3: Inscribed polygons (Archimedes)
We could approximate our circle of radius 1 by a regular hexagon inscribed in the circle, this would give an approximate perimeter of 6.
We can also define a process for better approximations:
Given an inscribed regular polygon we double the number of sides and calculate the perimeter of the new polygon.
We get a process like this:
number of sides length of one side circumference
--------------- ------------------ -------------
6 1.000 6.000
12 0.518 6.211
24 0.261 6.265
48 0.131 6.279
see for example Regular 12-gon
The circumference of the polygons quickly approach the circumference of the circle.
This Video (Youtube) shows how the approximations can be calculated using Pythagoras' formula.
Going from these better and better approximation to the true value is called "taking the limit" Wikipedia: Limit (mathematics)
The field of mathematics defining these limits rigurously and studying their properties is called calculus. Wikipedia: Calculus and for these problems of adding up "infinitely small" parts the tool of integration is used. Wikipedia: Integral
This article on arc length (Wikipedia) shows formulae for calculating the length of more general curves using calculus.
There is a demonstration of the process of approximating a circle with polygons available on Wolfram Alpha, however they are using it for the area of the circle rather than the circumference.