  We have developed a technique of isolating elongated structures in galactic
images, such as spiral arms, using anisotropic wavelets and apply this to maps
of the CO, infrared and radio continuum emission of the grand-design spiral
galaxy M51. Systematic shifts between the ridges of CO, infrared and radio
continuum emission that are several $\kpc$ long are identified, as well as
large variations in pitch angle along spiral arms, of a few tens of degrees. We
find two types of arms of polarized radio emission: one has a ridge close to
the ridge of CO, with similar pitch angles for the CO and polarization spirals
and the regular magnetic field; the other does not always coincide with the CO
arm and its pitch angle differs from the orientation of its regular magnetic
field. The offsets between ridges of regular magnetic field, dense gas and warm
dust are compatible with the sequence expected from spiral density wave
triggered star formation, with a delay of a few tens of millions of years
between gas entering the shock and the formation of giant molecular clouds and
a similar interval between the formation of the clouds and the emergence of
young star clusters. At the position of the CO arms the orientation of the
regular magnetic field is the same as the pitch angle of the spiral arm, but
away from the gaseous arms the orientation of the regular field varies
significantly. Spiral shock compression can explain the generation of one type
of arm of strong polarized radio emission but a different mechanism is probably
responsible for a second type of polarization arm. (Shortened abstract.)
