Search code examples
opencvimage-processingscalingimage-scaling

How to upscale only few points of an image, Image processing


I am working on an problem wherein I downscale an image find interesting points in the downscaled image sort of like a Binary Image. Now I want to upscale only the interesting points (i.e the white pixel points) that I found in the downscaled image instead of upscaling the whole image and then finding the interesting points. What technique can be best used for this purpose.


Solution

  • There is a simple relationship between the pixels in the downsampled image and those in the original image. For example, given an original image O that is downsampled by a factor 4 in each dimension, yielding a downsamapled image D, then a pixel (i,j) in D corresponds to a set of 4x4 pixels in O with the top-left pixel being (i*4,j*4) and the bottom-right pixel being (i*4+3j*4+3).

    Thus, after detecting a set of pixels in D, you can find the 4x4 patches corresponding to those pixels in O. There is no way of mapping your detection more precisely unless you are able to detect points in D with sub-pixel precision (e.g. by finding the location of a peak, which you can do by fitting a parabola or Gaussian to the peak).