久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 OpenCV 中測量邊緣強度,梯度大小

Measure edge strength in OpenCV, magnitude of gradient(在 OpenCV 中測量邊緣強度,梯度大小)
本文介紹了在 OpenCV 中測量邊緣強度,梯度大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個需要檢查相機焦點的應用程序.為此,我想在單個軸 (1D) 上的幾個預定義位置測量邊緣強度(梯度大小).圖像目標將是在一段時間背景上的黑色對象的簡單打印輸出.

I have an application where I need to check the focus of a camera. For this, I want to measure edge strength (magnitude of gradient) in several predefined locations on a single axis (1D). The image target will be a simple printout of black objects on a while background.

我在 Python 中使用 OpenCV.我知道 OpenCV 中有幾種邊緣檢測算法,例如 Canny、Sobel、laplace,但所有這些都是為了過濾圖像.我想實際測量邊緣的強度.OpenCV 中是否有任何算法可以提供此功能?還是我只是編寫自己的算法來測量邊緣強度?

I am using OpenCV with Python. I know there are several edge detection algorithms within OpenCV like Canny, Sobel, laplace but all of these are to filter the image. I want to actually measure the strength of an edge. Are there any algorithms within OpenCV that can provide this? Or do I just write my own algorithm to measure edge strength?

推薦答案

你可以像這樣計算量級:

You can compute the magnitude like:

  1. 計算 dxdy 導數(使用 cv::Sobel)
  2. 計算幅度sqrt(dx^2 + dy^2)(使用cv::magnitude)
  1. Compute dx and dy derivatives (using cv::Sobel)
  2. Compute the magnitude sqrt(dx^2 + dy^2) (using cv::magnitude)

這是一個計算梯度大小的簡單 C++ 代碼.您可以輕松移植到 Python,因為它只是對 OpenCV 函數的幾次調用:

This is a simple C++ code that compute the magnitude of the gradient. You can easily port to Python, since it's just a few calls to OpenCV functions:

#include <opencv2/opencv.hpp>
using namespace cv;

int main()
{
    //Load image
    Mat3b img = imread("path_to_image");

    //Convert to grayscale
    Mat1b gray;
    cvtColor(img, gray, COLOR_BGR2GRAY);

    //Compute dx and dy derivatives
    Mat1f dx, dy;
    Sobel(gray, dx, CV_32F, 1, 0);
    Sobel(gray, dy, CV_32F, 0, 1);

    //Compute gradient
    Mat1f magn;
    magnitude(dx, dy, magn);

    //Show gradient
    imshow("Magnitude", magn);
    waitKey();

    return 0;
}

這篇關于在 OpenCV 中測量邊緣強度,梯度大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 91精品麻豆日日躁夜夜躁 | 精品在线观看入口 | 亚洲综合二区 | 最近免费日本视频在线 | 狠狠亚洲 | 欧美日韩第一页 | 91看片视频 | 四虎精品在线 | 欧美性网站 | 久热国产精品 | 国产亚洲欧美在线 | 国产精品免费观看 | 欧美aⅴ| 亚洲高清视频在线观看 | 99热碰 | 久久久国产一区二区三区 | 天天干夜夜操视频 | 久久99视频免费观看 | 狠狠涩 | 久久精品小短片 | 91青青草视频 | 国产精品无码久久久久 | 日韩精品在线一区二区 | 久久精品福利 | 日韩最新网站 | 亚洲精品久 | 国产精品1区2区3区 欧美 中文字幕 | 中文字幕在线视频网站 | 国产精品视频一二三区 | 在线免费观看a级片 | 久久久九九 | 久久精品二区 | 五月免费视频 | 亚洲欧美视频 | 欧美精品一区二区三区视频 | 国产一区二区久久 | 羞羞视频网站免费看 | 亚洲天堂男人的天堂 | 日本黄色大片免费看 | 久久精品欧美一区二区三区麻豆 | 二区三区视频 |