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

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

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

問題描述

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

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 導(dǎo)數(shù)(使用 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 函數(shù)的幾次調(diào)用:

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;
}

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

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

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 中文字幕国产精品视频 | 五月天婷婷综合 | 欧美日一区| 亚洲成人高清 | 蜜桃精品视频在线 | 国内久久 | 99伊人 | 九九色九九 | 精品在线播放 | 91电影| 亚洲国产成人在线视频 | 91久久久久久久久久久久久 | 亚洲精品久久久蜜桃 | 成人精品鲁一区一区二区 | 羞羞色视频 | 日韩精品视频中文字幕 | 日韩成人一区 | 免费成人在线网站 | 欧美v免费 | 999久久久久久久久 国产欧美在线观看 | 成人影院av | 亚洲精品在线看 | 精品人伦一区二区三区蜜桃网站 | 国产精品视频免费观看 | 久久久亚洲成人 | 九九九久久国产免费 | 国产精品视频一二三区 | 激情福利视频 | 午夜精品久久久久99蜜 | 久久久国产视频 | 亚洲经典一区 | 免费在线观看一区二区三区 | 亚洲综合一区二区三区 | 久久久久国产一区二区三区 | 毛片久久久 | 欧美日韩国产一区二区 | 欧美性猛交一区二区三区精品 | 国产精品视频免费观看 | 亚洲精久 | 日本免费在线 | 精品日韩在线 |