We report on a microelectromechanical tunable optical filter incorporating strain-tunable nanoimprinted elastomeric grating with a pitch varied by 18%. This device enables tuning of optical fiber-guided laser wavelength between lambda=473 and 532 nm within 0.5 ms by mechanically modulating the pitch with a silicon microactuator. We also demonstrate the use of the device for obtaining two-color images of livedead-stained cells with the color intensity ratio varied by the actuator voltage applied. The small structure of the device integrated on a silicon chip may be used in portable systems for optical switching and spectroscopy.