Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c4717db

Browse files
Edge Detection
Sobel & Prewitt Operations
1 parent a5505dc commit c4717db

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed
43.4 KB
Loading[フレーム]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
%Prewitt
2+
3+
clc;
4+
clear all;
5+
a=imread('circuit.tif');
6+
[x y]=size(a);
7+
w=[-1 0 1; -1 0 1; -1 0 1];
8+
w1=[-1 -1 -1; 0 0 0; 1 1 1];
9+
%BW2 = edge(a,'Prewitt');
10+
a=double(a);
11+
for m=2:1:x-1
12+
for n=2:1:y-1
13+
r(m,n)=w(1)*a(m-1,n-1)+ w(2)*a(m,n-1)+w(3)*a(m+1,n-1)+w(4)*a(m-1,n)+w(5)*a(m,n)+w(6)*a(m+1,n)+w(7)*a(m-1,n+1)+w(8)*a(m,n+1)+w(9)*a(m+1,n+1);
14+
r1(m,n)=w1(1)*a(m-1,n-1)+ w1(2)*a(m,n-1)+w1(3)*a(m+1,n-1)+w1(4)*a(m-1,n)+w1(5)*a(m,n)+w1(6)*a(m+1,n)+w1(7)*a(m-1,n+1)+w1(8)*a(m,n+1)+w1(9)*a(m+1,n+1);
15+
end
16+
end
17+
z=r+r1;
18+
19+
%for m=1:1:x
20+
% for n=1:1:y
21+
subplot(1,4,1);
22+
imshow(uint8(a));
23+
subplot(1,4,2);
24+
imshow(uint8(r));
25+
subplot(1,4,3);
26+
imshow(uint8(r1));
27+
subplot(1,4,4);
28+
imshow(uint8(z));
50.2 KB
Loading[フレーム]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
%Sobel
2+
3+
clc;
4+
clear all;
5+
a=imread('circuit.tif');
6+
[x y]=size(a);
7+
w=[-1 0 1; -2 0 2; -1 0 1];
8+
w1=[-1 -2 -1; 0 0 0; 1 2 1];
9+
%BW2 = edge(a,'Prewitt');
10+
a=double(a);
11+
for m=2:1:x-1
12+
for n=2:1:y-1
13+
r(m,n)=w(1)*a(m-1,n-1)+ w(2)*a(m,n-1)+w(3)*a(m+1,n-1)+w(4)*a(m-1,n)+w(5)*a(m,n)+w(6)*a(m+1,n)+w(7)*a(m-1,n+1)+w(8)*a(m,n+1)+w(9)*a(m+1,n+1);
14+
r1(m,n)=w1(1)*a(m-1,n-1)+ w1(2)*a(m,n-1)+w1(3)*a(m+1,n-1)+w1(4)*a(m-1,n)+w1(5)*a(m,n)+w1(6)*a(m+1,n)+w1(7)*a(m-1,n+1)+w1(8)*a(m,n+1)+w1(9)*a(m+1,n+1);
15+
end
16+
end
17+
z=r+r1;
18+
19+
%for m=1:1:x
20+
% for n=1:1:y
21+
subplot(1,4,1);
22+
imshow(uint8(a));
23+
subplot(1,4,2);
24+
imshow(uint8(r));
25+
subplot(1,4,3);
26+
imshow(uint8(r1));
27+
subplot(1,4,4);
28+
imshow(uint8(z));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /