Whatever line or space the note is on, is the line or space you start counting from (it is the 1). In the example, the first line of the staff, E, is 1, since the note-head is on that line.
When E is 1, the F space is some type of 2, the G line is some type of 3, the A space is some type of 4, the B line is some type of 5, the C space is some type of 6, the D line is some type of 7, the E space is some type of 8.
The type will depend on whether the tones are naturals, sharps, or flats [aka the key signature].
With time & practice, we can quickly identify interval types in notation by how they look. The challenge can be what type of 2, 3, 6, etc. This will depend on the key signature and whether sharps or flats are present.
Visually, it helps to know the following. In music notation rules, visual spacing allows use to quickly identify interval types. Pairing this information with knowledge of the fretboard and guitar intervals, we can interpret more efficiently, even without having to keep note-tone names in mind, as in the case of transposing.
When we play a scale, one tone to the next to the next, this is playing in steps (2nds). Steps are 2nds. E to F is a 2nd. F to G is a 2nd. Yet, E to F is one fret, while F to G is two frets. Therefore, there must be two types of 2nds [a one fret 2nd, & two fret 2nd]. This is true. And, this idea applies to 2nds, 3rds, 6ths, & 7ths.
A one fret 2nd is called a minor 2nd [m2] = 1 half-step = 1 fret
A two fret 2nd is called a Major 2nd [M2] = 2 half-steps = 2 frets