SayCoo論壇

查看: 8734|回復: 1
打印 上一主題 下一主題

MATLAB roberts濾波法

[複製鏈接]
跳轉到指定樓層
1
發表於 2006-8-29 22:16:12 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
roberts 濾波法是屬於一種梯度的濾波法,
形成一個2值影像, 並得到邊緣強化.

roberts是一個2*2的遮罩.
因為偷懶了幾天, 所以今天才做出來.

順便附上銳化的程式

************************ROBERTS邊緣強化
clear all, close all;
[x,map]=imread('F:\My Documents\3-18.jpg');
figure, imshow(x); %make 1 figure to show image.
%x=rgb2gray(x);% rgb -> gray
n=double(x);
%figure(2), imshow(n);
n1=double(n);
[x,y,z]=size(n1) ;
b=zeros(x,y,z); %Matrix of full image
r=zeros(1,4); %matrix of filter with 2 * 2.
for q=1:3 ;% rgb
    for o=1:x-1 ;
        for p=1:y-1 ;
            r(1)=n1(o,p,q);
            r(2)=0;
            r(3)=0;
            r(4)=-n1(o+1,p+1,q);
            j1(o,p,q)=abs(sum(sum(r)));
        end
    end
end

for q=1:3 ;% rgb
    for o=1:x-1;
        for p=1:y-1 ;
            r(1)=0;
            r(2)=n1(o,p+1,q);
            r(3)=-n1(o+1,p,q);
            r(4)=0;
            j2(o,p,q)=abs(sum(sum(r)));
        end
    end
end
n3=uint8(j1+j2);
figure,imshow(n3);
            
*****************************銳化3X3

[x,map]=imread('F:\My Documents\3-18.jpg');
%figure,imshow(x);
imshow(x);
m2 = imcrop(x);
figure(2)
imshow(m2)
x2=double(m2);
[x,y,z]=size(x2);
imfull=zeros(x,y,z);
filter=zeros(3,3);
for q=1:3;
    for o=2:x-1;
        for p=2:y-1;
            filter(1,1)=-x2(o-1,p-1,q);
            filter(1,2)=-x2(o-1,p,q);
            filter(1,3)=-x2(o-1,p+1,q);
            filter(2,1)=-x2(o,p-1,q);
            filter(2,2)=9*x2(o,p,q);
            filter(2,3)=-x2(o,p+1,q);
            filter(3,1)=-x2(o+1,p-1,q);
            filter(3,2)=-x2(o+1,p,q);
            filter(3,3)=-x2(o+1,p+1,q);
            imfull(o,p,q)=sum(sum(filter))/1;
        end
    end
end
n2=uint8(imfull);
figure(9);imshow(n2);
%BW=im2bw(n,0.7);
%figure(4), imshow(BW);
            
******************銳化5x5我也有寫, 但是寫出來發現銳化的原理跟柔化不同,
銳化是數值的搭配, 紅色部分, 中心點的乘數, 剪掉其他遮罩的負數, 得到的數字, 除以總遮罩的除數, 必須得到商數為1
中心數字越大, 越為銳化!!
2
發表於 2011-5-17 01:45:10 | 只看該作者
thank you very much
回復 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 加入會員

本版積分規則

手機版|黑名單|SayCoo論壇

GMT+8, 2024-4-27 04:41

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表