I am new to OpenCV and DSP. I want to code a filter which act like a real optical filter. When you filter the image, the output looks like shotted with a $550nm$ optical filter lens. Like a Bandpass filter for image. I wanna filter all lights below $550nm $ wavelength.

Is it possible with OpenCV? How can Ii do that? Filter2D or Gabor Filter?

Sorry for my English and sorry if the question is irrevelent.


  • 1
    $\begingroup$ How is your image represented? RGB? Luminance/chroma? Something else? $\endgroup$ – Jim Clay Mar 28 '12 at 14:25
  • $\begingroup$ So you want to get keep all light above 550 nm and get rid of all light below 550 nm? $\endgroup$ – Jim Clay Mar 28 '12 at 15:27
  • $\begingroup$ yes my image is rgb and i need all lights above 550 nm $\endgroup$ – juds Mar 28 '12 at 15:35
  • 1
    $\begingroup$ If you need all colors above 550nm, just take the red channel. $\endgroup$ – nibot Mar 29 '12 at 8:10
  • $\begingroup$ This might prove useful to you: scientificbulletin.upb.ro/rev_docs_arhiva/full49129.pdf I think it is relevant to the topic of discussion here. $\endgroup$ – user5353 Aug 31 '13 at 20:15

In general this is not possible, since you do not have full spectral information for each pixel, but only coordinates in some low-dimensional color space (i.e. RGB).

If your image data is in RGB, then the best you can do is to simply take the green color channel (which will be most responsive to 550 nm) and throw away the red and blue.

Depending on the actual response of your RGB channels, you might be able to better estimate the 550nm contribution via a linear combination of red and green (see Spectral Sensitivity).

  • $\begingroup$ my image is RGB $\endgroup$ – juds Mar 28 '12 at 15:05
  • $\begingroup$ I don't understand your answer. With signals we don't have all spectral information in a single sample either. So what? The spectral information comes from the set of samples, and the set of pixels. $\endgroup$ – Jim Clay Mar 28 '12 at 15:05
  • 2
    $\begingroup$ If we had a very fast movie instead of an image, then we could get the (color) spectral information out in the way that you suggest. But this movie would have to be sampled at optical frequencies, i.e. faster than c/(550 nm)=10^14 Hz. This is not really possible. $\endgroup$ – nibot Mar 28 '12 at 15:10
  • $\begingroup$ You can think of an RGB image as being made by passing the light through three bandpass filters (one each for R, G, and B) and recording the power seen in each filtered signal. Finer-grained (color) spectral information is lost. $\endgroup$ – nibot Mar 28 '12 at 15:11
  • 2
    $\begingroup$ @juds: This idea is foiled by the existence of non-spectral colors. It is simply not possible to isolate a given wavelength given RGB values. However, you can probably achieve the desired effect by converting to HSV color space and selecting a particular range of hues. $\endgroup$ – nibot Mar 28 '12 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.