久久久久久久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 導數(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ù)的幾次調用:

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模板網(wǎng)!

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(liá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?(如何在圖像的多個矩形邊界框中應用閾值?)
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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 色婷婷影视| 欧美日韩一二三区 | 成人免费毛片嘿嘿连载视频 | 亚洲日本中文字幕 | 国产欧美日韩一区二区三区 | 国产a久久麻豆入口 | 欧美日韩三区 | 国产免费高清 | 国产精品一区二区三区四区 | av免费网站| 国产精品一区二区在线免费观看 | 日韩视频在线观看 | 日韩精品成人 | 黑森林av | 99精品久久久久久中文字幕 | 成人小视频在线观看 | 日韩欧美一级片 | 91在| 欧美日韩免费视频 | 中文字幕第7页 | 第一福利丝瓜av导航 | 青草视频在线播放 | hdxxxxhd100%| 色播av| 欧美日韩亚洲天堂 | 午夜免费影院 | 国产黄色一区 | 九九色影院 | 欧美在线天堂 | 国产伦精品一区二区三区四区免费 | 不卡av在线播放 | 国产理论在线观看 | 成人9ⅰ免费影视网站 | 午夜免费看片 | 免费av网址在线观看 | 久久精品黄色 | 一级做a爰片久久毛片潮喷 视频一二区 | 国产精品成人在线 | 在线中文字幕视频 | 女人一级一片30分 | 中文字幕日韩欧美 |