matlab實現圖像浮雕效果
1 概述
浮雕在我們現實生活中處處可見,尤其是中國古代的建築浮雕衆多。浮雕既是一種刻在磚、石壁或木頭上的一種雕塑。
圖像處理算法原理:newpixel(i,j) = pixel(i,j)-pixel(i,j+1)+TH
i爲圖像高度,j爲圖像寬度,pixel爲當前圖像像素點,TH爲閾值(0-255)。
2 matlab實現
Matlab實驗TH均取100。
實驗原圖:
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實驗結果:
歡迎關注微信公衆號:FPGA開源工作室
獲取更多學習資料。