Filters on floating-point images

It seems the default filters for images (filter.boxMedian for example) doesn’t accept f32bpp images such as obtained as heightmaps. How would one filter heightmap images obtained from cvb? Of course the crude approach would be to convert the data type, but this results in the loss of a lot of information, which I’d like to avoid if at all possible.

Hi @CvK

the support for floating-point valued images in the CVFoundation.dll functions unfortunately is a fairly jagged terrain. I’ll add a rough list of functions that support this data format to the bottom of this post.

Where support for floating point valued input is not given, I fear that you’ll either need to go through a different data format (accepting that there might be some information loss, but the extent to which this hurts greatly depends on the range of values in the floating point image) or try to build the missing link with what is there (which might be possible e.g. for some of the simpler filter operations).

The functions that - according to a look at the sources - support 32 bit floating point images are:
(note: this list is based on the input checks in the source code - assuming that these are written correctly these functions should support 32 bit floating point images…)

  • AbsoluteImage
  • AddConstant
  • AddImages
  • ApplyColorTwistMatrix
  • ApplyForwardGammaCorrection
  • ApplyInverseGammaCorrection
  • AreaSubImage
  • BlackHatImage
  • CalculateCorrelationCoefficients
  • CalculateCrossCorrelations
  • CalculateSumOfSquareDistances
  • ConvertHLSToRGB
  • ConvertRGBToLUV
  • ConvertRGBToGrayScale
  • ConvertRGBToGrayScaleStandard
  • ConvertRGBToHLS
  • ConvertRGBToXYZ
  • ConvertRGBToYCC
  • ConvertLUVToRGB
  • ConvertXYZToRGB
  • ConvertYCCToRGB
  • CreateConstantThresholdImage
  • CreateImageThresholdImage
  • CreateTransparentThresholdImage
  • DivideConstant
  • DivideImages
  • DynThresholdImageMinMax
  • DilateImage
  • ErodeImage
  • FilterBoxMax
  • FilterBoxMean
  • FilterBoxMin
  • FilterGauss
  • FilterHiPass
  • FilterLaplace2
  • FilterLoPass
  • FilterMedianColor
  • FilterPrewittHorizontal
  • FilterPrewittVertical
  • FilterRobertsDown
  • FilterRobertsUp
  • FilterScharrHorizontal
  • FilterScharrVertical
  • FilterSharpening
  • FilterSobelCross
  • FilterSobelHorizontal
  • FilterSobelHorizontal2ndOrder
  • FilterSobelVertical
  • FilterSobelVertical2ndOrder
  • FilterUserLinear
  • FilterWiener
  • ForwardWaveletTransform
  • ImageMinMaxValue
  • ImageNormL1
  • ImageNormL2
  • ImageNormLInf
  • InitializeImageRectFloat
  • InverseWaveletTransform
  • MatrixTransformImage
  • MorphologicalGradientImage
  • MultiplyConstant
  • MultiplyImages
  • PerspectiveTransformImage
  • PyramidDownSample
  • PyramidUpSample
  • ResizeImage
  • RotateImage
  • ShearImage
  • SquareImage
  • SquareRootImage
  • SubtractConstant
  • SubtractConstantAbsolute
  • SubtractImages
  • SubtractImagesAbsolute
  • TopHatImage
  • WangImageQuality

Hmm, I found a working solution but it feels kind of hack-y. Being the duct-tape engineer that I am, I tried to get the color median filter to work since this one does accept floating point values. It worked after I copied the first plane two times to create an RGB encoded image. Strange that the original median doesn’t work though.