The staining algorithm is introduced to improve the signal-tonoise ratio (S/N) of poorly illuminated subsurface structures in seismic imaging. However, the amplitudes of the original and the stained wavefield, i.e., the real and the imaginary wavefields, differ by several orders of magnitude, and the waveform of the stained wavefield may be greatly distorted. We have developed a generalized staining algorithm (GSA) to achieve amplitude preservation in the stained wavefield. The real wavefield and the stained wavefield propagate in the same velocity model. A source wavelet is used as the source of the real wavefield; however, the real wavefield is extracted from the stained area as the source of the stained wavefield. The GSA maintains some properties of the original staining algorithm. The stained wavefield is synchronized with the real wavefield, and it contains only information relevant to the target region. By imaging with the stained wavefield, we obtain higher S/Ns in images of target structures. The most significant advantage of our method is the amplitude preservation of the stained wavefield, which means that this method could potentially be used in quantitative illumination analysis and velocity model building. The GSA could be adopted easily for frequencydomain wavefield propagators and time-domain propagators. Furthermore, the GSA can generate any number of stained wavefields. Numerical experiments demonstrate these features of the GSA, and we apply this method in target-oriented modeling and imaging as well as obtaining amplitude-preserved stained wavefields and higher S/Ns in images of target structures.