久久久久久久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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 国产精久久久久久久 | 日本不卡在线视频 | 日韩av成人 | www精品| 国产精品免费播放 | 国产精品久久久久久久久久妞妞 | 少妇黄色 | 亚洲欧美日韩精品久久亚洲区 | 人人做人人澡人人爽欧美 | 国产欧美一区二区三区在线看 | 国产精品18久久久久久白浆动漫 | 国产一区二 | 亚洲午夜av久久乱码 | 资源首页二三区 | 久操伊人| 国产精品免费在线 | 中文字幕国产视频 | 精品中文字幕视频 | 6996成人影院网在线播放 | 亚洲精品日韩视频 | 天堂网中文字幕在线观看 | 91久久精品 | 精品二三区 | 成人动漫一区二区 | 99久久久久久久 | jvid精品资源在线观看 | 中文字幕亚洲精品在线观看 | 91免费视频 | 久久婷婷国产麻豆91 | 成人国产在线视频 | 国产精品久久视频 | 午夜天堂精品久久久久 | 天天天操| 亚洲精品1区 | 欧美456| 九九热精品在线 | 欧一区二区| 色在线免费 | 免费在线观看av网址 | 成人亚洲| 欧美视频精品 |