Imagery is essential in "When I Heard the Learn'd Astronomer." In particular, Whitman uses visual and auditory imagery to contrast the lecture room of the first half of the poem with the great outdoors of the second half. Consequently, by highlighting the contrast, Whitman suggests the preferability of the great outdoors over the lecture room, along with each setting's associated philosophies.
The auditory imagery (i.e. the things the speaker hears) highlights the contrast between the unbearable noisiness of the lecture room and the peaceful silence of the great outdoors. In lines 1 and 4 the speaker listens to the astronomer's lecture. Moreover, in line 4, the imagery highlights that there is "much applause" in the room. The noise of the astronomer's wordy lecture builds up to this thunderous applause and is, consequently, too noisy for the speaker to take.
In contrast, the imagery of the second half of the poem highlights the peace and quiet of the outdoors. In line 6, the speaker departs the lecture room, leaving such a noisy setting. Additionally, the speaker departs alone; thus, no one talks to or around the speaker. Moreover, the last line of the poem stresses the "perfect silence" of nature. As the adjective "perfect" is attached to the idea of "silence," the poem makes clear its preference for the "silence" and peace of the outdoors.
The visual imagery of the poem also highlights the speaker's preference for the great outdoors. Lines 2 and 3 are filled with scientific and mathematical imagery of "proofs," "figures," "columns," "charts," and "diagrams." These images are presented in a list-like manner, highlighting the dull monotony of the astronomer's lecture. In contrast, the latter half of the poem that describes the great outdoors is filled with playful, almost fairy-tale like imagery. In line 6, the speaker, for example "ris[es] and glid[es]" out of the lecture room. The act of "rising and gliding" is associated with ethereal figures such as fairies or angels, as it is a far more graceful act than a lumbering walk. Therefore, simply by leaving the lecture room, the speaker gains a quality of etherealness.
In a similar vein in line 7, the poem uses imagery to describe the "mystical" quality of the surroundings, which are filled with "moist night-air." Additionally, the last line ends on an image of the "stars." Consequently, the imagery of the last four lines emphasizes the magical—almost divine—quality of the outdoors. The poem, thus, clearly suggests that nature contains peace and divinity that cannot be found within manmade institutions.