一。 Sobel簡介
一句話可以概況為,分別求水平與豎直梯度,然后求平方和再開方(近似的話就直接求絕對值之和),最后與設(shè)定的閾值進(jìn)行比較,大于的話就賦值為0,小于的話就賦值為255
x方向梯度dx的求法:3*3的圖像矩陣與下面的矩陣在對應(yīng)位置相乘然后相加
y方向梯度dy的求法:同上
二。 代碼實(shí)現(xiàn)
這里采用近似計(jì)算G = |dx| + |dy|,正負(fù)號分開計(jì)算,然后用大的數(shù)減去小的數(shù)
reg[10:0] Sobel_px ,Sobel_nx;reg[10:0] Sobel_py ,Sobel_ny;
wire[10:0] Sobel_x;wire[10:0] Sobel_y;
wire[7:0] Sobel_data;
//x方向的梯度assign Sobel_x = (Sobel_px 》 Sobel_nx) ? (Sobel_px - Sobel_nx) : (Sobel_nx - Sobel_px);//y方向的梯度assign Sobel_y = (Sobel_py 》 Sobel_ny) ? (Sobel_py - Sobel_ny) : (Sobel_ny - Sobel_py);assign Sobel_data = (Sobel_x + Sobel_y 》 ‘d135) ? ’d0 : ‘d255;
always@(posedge clk_9M or negedge rst)begin if(rst == 1’b0) begin Sobel_px 《= ‘d0; Sobel_nx 《= ’d0; end else if(cur_x 》= ‘d100 && cur_x 《= ’d199 && cur_y 》= ‘d50) begin Sobel_nx 《= data_line_11 + data_line_21 + data_line_21 + data_line_31; Sobel_px 《= data_line_13 + data_line_23 + data_line_23 + data_line_33; end else begin Sobel_nx 《= ’d0; Sobel_px 《= ‘d0; endend
always@(posedge clk_9M or negedge rst)begin if(rst == 1’b0) begin Sobel_py 《= ‘d0; Sobel_ny 《= ’d0; end else if(cur_x 》= ‘d100 && cur_x 《= ’d199 && cur_y 》= ‘d50) begin Sobel_py 《= data_line_11 + data_line_12 + data_line_12 + data_line_13; Sobel_ny 《= data_line_31 + data_line_32 + data_line_32+ data_line_33; end else begin Sobel_ny 《= ’d0; Sobel_py 《= ‘d0; endend
編輯:lyn
-
FPGA
+關(guān)注
關(guān)注
1645文章
22050瀏覽量
618502 -
sobel
+關(guān)注
關(guān)注
0文章
12瀏覽量
8064
原文標(biāo)題:FPGA實(shí)現(xiàn)Sobel邊緣檢測
文章出處:【微信號:zhuyandz,微信公眾號:FPGA之家】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
基于FPGA的壓縮算法加速實(shí)現(xiàn)

Linux系統(tǒng)中通過預(yù)留物理內(nèi)存實(shí)現(xiàn)ARM與FPGA高效通信的方法

基于FPGA實(shí)現(xiàn)圖像直方圖設(shè)計(jì)

FPGA驅(qū)動AD芯片之實(shí)現(xiàn)與芯片通信

ADS1299 FPGA驅(qū)動,是否成功實(shí)現(xiàn)了?應(yīng)該如何初始化呢?
FPGA中浮點(diǎn)四則運(yùn)算的實(shí)現(xiàn)過程

FPGA在物聯(lián)網(wǎng)中的應(yīng)用前景
FPGA在數(shù)據(jù)處理中的應(yīng)用實(shí)例
基于 DSP5509 進(jìn)行數(shù)字圖像處理中 Sobel 算子邊緣檢測的硬件連接電路圖
使用內(nèi)部限流器實(shí)現(xiàn)恒流運(yùn)行應(yīng)用簡介

FPGA + USB2.0 PHY USB3300 實(shí)現(xiàn)高速USB2UART
如何在FPGA中實(shí)現(xiàn)按鍵消抖
優(yōu)化 FPGA HLS 設(shè)計(jì)
如何在FPGA中實(shí)現(xiàn)隨機(jī)數(shù)發(fā)生器

評論