This application discloses a virtual
staining method, apparatus, device, and medium for images, relating to the field of
image processing technology. The method includes: inputting an image of tissue to be stained into a preset morphological instance detection model to locate morphological structural units of a preset category in the image, obtaining corresponding bounding box sets, and generating a target
mask; inputting the image of tissue to be stained into a preset virtual
staining generation model, performing
staining transformation on the image of tissue to be stained through a global virtual staining path to generate a global staining result, and performing staining
processing on the image regions where the morphological structural units in the image of tissue to be stained are located through instance virtual staining paths and according to the bounding box sets to generate instance staining results; performing geometric deformation correction
processing on the instance staining results and outputting corrected instance staining results; and performing weighted summation and residual repair
processing on the global staining results, corrected instance staining results, and target
mask to generate a target virtual staining image. This achieves high-quality virtual staining.