www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當(dāng)前位置:首頁(yè) > > FPGA開(kāi)源工作室

FPGA實(shí)現(xiàn)圖像浮雕效果

1 概述

浮雕在我們現(xiàn)實(shí)生活中處處可見(jiàn),尤其是中國(guó)古代的建筑浮雕眾多。浮雕既是一種刻在磚、石壁或木頭上的一種雕塑。

圖像處理算法原理:newpixel(i,j) = pixel(i,j)-pixel(i,j+1)+TH

i為圖像高度,j為圖像寬度,pixel為當(dāng)前圖像像素點(diǎn),TH為閾值(0-255)。

2 matlab實(shí)現(xiàn)

Matlab實(shí)驗(yàn)TH均取100

實(shí)驗(yàn)原圖:

Matlab源碼:

close all

clear all

clc

Irgb = imread('1.bmp');%

Igray= rgb2gray(Irgb);

[Height,Width,Dim] = size(Irgb);

Inew = zeros(Height,Width);

TH = 100;

for i = 1:Height

for j=1:Width-1

Inew(i,j)=Igray(i,j)-Igray(i,j+1)+TH;

%Inew(i,j)=Igray(i,j+1)-Igray(i,j)+100;

if Inew(i,j) >255

Inew(i,j) = 255;

elseif Inew(i,j) <0

Inew(i,j) = 0;

else

Inew(i,j) =  Inew(i,j);

end

end

end

Inew = uint8(Inew);

subplot(221),imshow(Irgb);

subplot(222),imshow(Igray);

subplot(223),imshow(Inew);

subplot(224),imshow(Irgb);

Matlab實(shí)驗(yàn)結(jié)果:

3 FPGA實(shí)現(xiàn)

FPGA實(shí)現(xiàn)浮雕效果算法過(guò)程:

1,RGB圖像轉(zhuǎn)換為灰度圖像

2,對(duì)灰度圖像進(jìn)行浮雕算法處理實(shí)現(xiàn)浮雕效果

FPGA源碼:

/**********************************

copyright@FPGA OPEN SOURCE STUDIO

微信公眾號(hào):FPGA開(kāi)源工作室

Algorithm:emboss = img(i,j)-img(i,j+1)+TH

Description:i--Image height

j--Image width

TH --[0 255]

***********************************/

module emboss#(

parameter DW = 24,

parameter TH                = 100

)(

input pixelclk,

input reset_n,

input [DW-1:0] din,//gray in

input i_hsync,

input i_vsync,

input i_de,

output [DW-1:0]dout,//emboss out

output o_hsync,

output o_vsync,

output o_de

);


wire [7:0] gray = din[23:16]; //img(i,j)

reg  [7:0] gray_r;//img(i,j+1)

reg signed [9:0] emboss_r;//10bit signed -512 --511

reg  [7:0] dout_r;

reg         hsync_r0,hsync_r1;

reg         vsync_r0,vsync_r1;

reg         de_r0,de_r1;

assign o_hsync = hsync_r1;

assign o_vsync = vsync_r1;

assign o_de = de_r1;

assign dout = {dout_r,dout_r,dout_r};

//synchronization

always @(posedge pixelclk) begin

hsync_r0 <= i_hsync;

vsync_r0 <= i_vsync;

de_r0 <= i_de;

hsync_r1 <= hsync_r0;

vsync_r1 <= vsync_r0;

de_r1 <= de_r0;

end

//pipeline

always @(posedge pixelclk) begin

if(!reset_n)

gray_r <= 0;

else

gray_r <= gray;

end

always @(posedge pixelclk or negedge reset_n)begin

if(!reset_n) begin

emboss_r<= 0;

dout_r <= 0;

end

else begin

emboss_r<= gray-gray_r+TH;//max 355 min -155

if(emboss_r>255) dout_r <= 255;

else if(emboss_r<0) dout_r <= 0;

else dout_r <= emboss_r[7:0];

end

end

Endmodule

FPGA實(shí)現(xiàn)效果:


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
關(guān)閉