Both UV and IR are electromagnetic radiations and will need separate detectors. These detectors will convert the UV/ IR radiation in to a digital signal that will be used for imaging.
Different ingredients in food will have different UV/ IR wavelength and the imaging system should be capable of differentiating these differential emissions.
UV radiation (a high frequency) is reflected by the sensed object... the energy you use for that aim comes from an external source... on the other hand, thermal radiation (a low frequency) is emitted by the sensed object, so the energy comes from the object itself.
If you are able to get the spectrum of an object and you know the spectrum of every single element that is in the object, you should be able to guess how much of each element is not that object.