zoukankan      html  css  js  c++  java
  • 反向投影的工作原理

    1.反向投影的作用是什么?
        反向投影用于在输入图像(通常较大)中查找特定图像(通常较小或者仅1个像素,以下将其称为模板图像)最匹配的点或者区域,也就是定位模板图像出现在输入图像的位置。
    2.反向投影工作原理
        查找的方式就是不断的在输入图像中切割跟模板图像大小一致的图像块,并用直方图对比的方式与模板图像进行比较。

    例如我们有一张100x100的输入图像,有一张10x10的模板图像,查找的过程是这样的:
    (1)从输入图像的左上角(0,0)开始,切割一块(0,0)至(10,10)的临时图像;
    (2)生成临时图像的直方图;
    (3)用临时图像的直方图和模板图像的直方图对比,对比结果记为c;
    (4)直方图对比结果c,就是结果图像(0,0)处的像素值;
    (5)切割输入图像从(0,1)至(10,11)的临时图像,对比直方图,并记录到结果图像;
    (6)重复(1)~(5)步直到输入图像的右下角。

    calcBackProject

    Calculates the back projection of a histogram.
    C++: void calcBackProject(const Mat* arrays, int narrays, const int* channels, InputArray hist, OutputArray
    backProject, const float** ranges, double scale=1, bool uniform=
    true )
    C++: void calcBackProject(const Mat* arrays, int narrays, const int* channels, const SparseMat& hist,
    OutputArray backProject, const float** ranges, double scale=1, bool uniform=
    true )
    Python: cv2.calcBackProject(images, channels, hist, ranges[, dst[, scale ]]) !dst
    C: void cvCalcBackProject(IplImage** image, CvArr* backProject, const CvHistogram* hist)
    Python: cv.CalcBackProject(image, backProject, hist) !None
    Parameters

    Mat 类型
    arrays – Source arrays. They all should have the same depth, CV_8U or CV_32F , and the
    same size. Each of them can have an arbitrary number of channels.


    narrays – Number of source arrays.


    channels – The list of channels used to compute the back projection. The number of
    channels must match the histogram dimensionality. The first array channels are numerated
    from 0 to arrays[0].channels()-1 , the second array channels are counted from
    arrays[0].channels() to arrays[0].channels() + arrays[1].channels()-1, and
    so on.


    hist – Input histogram that can be dense or sparse.


    backProject – Destination back projection aray that is a single-channel array of the same
    size and depth as arrays[0] .

    ranges – Array of arrays of the histogram bin boundaries in each dimension. See calcHist() .

    scale – Optional scale factor for the output back projection.

    //是否归一化
    uniform – Flag indicating whether the histogram is uniform or not (see above).


    The functions calcBackProject calculate the back project of the histogram. That is, similarly to calcHist , at
    each location (x, y) the function collects the values from the selected channels in the input images and finds the
    corresponding histogram bin. But instead of incrementing it, the function reads the bin value, scales it by scale ,
    and stores in backProject(x,y) . In terms of statistics, the function computes probability of each element value in
    respect with the empirical probability distribution represented by the histogram. See how, for example, you can find
    and track a bright-colored object in a scene:
    1. Before tracking, show the object to the camera so that it covers almost the whole frame. Calculate a hue
    histogram. The histogram may have strong maximums, corresponding to the dominant colors in the object.
    2. When tracking, calculate a back projection of a hue plane of each input video frame using that pre-computed
    histogram. Threshold the back projection to suppress weak colors. It may also make sense to suppress pixels
    with non-sufficient color saturation and too dark or too bright pixels.
    3. Find connected components in the resulting picture and choose, for example, the largest component.
    This is an approximate algorithm of the CamShift() color object tracker.

    是时候好好总结下自己走过的路。
  • 相关阅读:
    "此页的状态信息无效,可能已损坏。”的解决办法 dodo
    C#AdServer相关操作 dodo
    E: 有未能满足的依赖关系。请尝试不指明软件包的名字来运行“aptget f install”(也可以指定一个解决办法)。 dodo
    通过ASP.NET连接Oracle数据库 dodo
    System.Runtime.InteropServices.ExternalException: GDI+ 中发生一般性错误 dodo
    FAT32转NTFS无法输入正确卷标 dodo
    Virtual PC 虚拟机虚拟硬盘压缩 dodo
    Destination host unreachable 一般解决办法 dodo
    15个优秀的第三方 Web 技术集成 dodo
    asp.net 2.0关于NavigateUrl中绑定Eval()方法时出现"服务器标记的格式不正确"的解决方法 dodo
  • 原文地址:https://www.cnblogs.com/haoxing990/p/4574722.html
Copyright © 2011-2022 走看看