diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6d2e53c Binary files /dev/null and b/.DS_Store differ diff --git a/lena.png b/edge_detection/lena.png similarity index 100% rename from lena.png rename to edge_detection/lena.png diff --git a/lina.png b/edge_detection/lina.png similarity index 100% rename from lina.png rename to edge_detection/lina.png diff --git a/sobel.m b/edge_detection/sobel.m similarity index 76% rename from sobel.m rename to edge_detection/sobel.m index a01c7ee..d358be0 100644 --- a/sobel.m +++ b/edge_detection/sobel.m @@ -10,10 +10,15 @@ % mask application -Xmask= [-1 -2 -1 ; +Ymask= [-1 -2 -1 ; 0 0 0 ; 1 2 1]; -Ymask= [-1 0 1 ; + +tymask= [-1 -2 -3 -2 -1 ; + 0 0 0 0 0 ; + -1 -2 -3 -2 -1 ]; + +Xmask= [-1 0 1 ; -2 0 2 ; -1 0 1]; z1mask=[ 0 1 2 ; @@ -30,30 +35,30 @@ for idx= 1:(r-3) for jdx = 1:(c-3) Lsquare = Ldbl(idx:(idx+2),jdx:(jdx+2)); - res= Xmask.*Lsquare; + res= Ymask.*Lsquare; OUT(idx,jdx)=sum(sum(res)); end end -Gx = OUT; +Gy = OUT; figure() -imshow(Gx) -title('edges along x axis'); +imshow((Gy),[]) +title('edges along Y axis'); -%applying mask along y +%applying mask along x for idx= 1:(r-3) for jdx = 1:(c-3) Lsquare = Ldbl(idx:(idx+2),jdx:(jdx+2)); - res= Ymask.*Lsquare; + res= Xmask.*Lsquare; OUT(idx,jdx)=sum(sum(res)); end end -Gy = OUT; +Gx = OUT; figure() -imshow(Gy) -title('edges along y axis'); +imshow((Gx),[]) +title('edges along x axis'); %applying mask along z1 @@ -68,7 +73,7 @@ Gz1 = OUT; figure() -imshow(Gz1) +imshow((Gz1),[]) title('edges along z axis'); @@ -84,7 +89,7 @@ Gz2 = OUT; figure() -imshow(Gz2) +imshow((Gz2),[]) title('edges along z axis'); @@ -95,9 +100,14 @@ imshow((mag),[]); % displays the grayscale image based the range of pixel values title('image magnitude'); -ort= atan(Gx/Gy); +ort= atan(Gy./Gx); figure() -imshow(ort) +imshow((ort),[]); + +meg=sqrt(Gz2.^2 + Gz1.^2); % magnitude of image +figure() +imshow((mag),[]); % displays the grayscale image based the range of pixel values +title('image magnitude'); diff --git a/edge_detection/test.m b/edge_detection/test.m new file mode 100644 index 0000000..80918d9 --- /dev/null +++ b/edge_detection/test.m @@ -0,0 +1,19 @@ + L = imread('lena.png'); + [Gmag, Gdir] = imgradient(L,'sobel'); + BW = edge(L); + BW2 = edge(L,'sobel','vertical'); + BW23 = edge(L,'sobel','horizontal'); + BW4 = edge(L,'sobel'); + + figure() + imshow(BW2) + title('filter along Y axis') + + figure + imshow(BW23) + title('filter along X axis') + + + figure + imshow(BW4) + title('Image magnitud') diff --git a/edge_detection/test.m~ b/edge_detection/test.m~ new file mode 100644 index 0000000..eab58aa --- /dev/null +++ b/edge_detection/test.m~ @@ -0,0 +1,7 @@ + L = imread('lena.png'); + [Gmag, Gdir] = imgradient(L,'sobel'); + BW = edge(L); + BW2 = edge(L,'sobel','vertical'); + BW23 = edge(L,'sobel','horizontal'); + imshow(BW2) + im \ No newline at end of file diff --git a/test.m b/test.m deleted file mode 100644 index 430d7b9..0000000 --- a/test.m +++ /dev/null @@ -1,7 +0,0 @@ -codegen sobel -im = imread('hello.jpg'); -image(im); -gray = (0.2989 * double(im(:,:,1)) + 0.5870 * double(im(:,:,2)) + 0.1140 * double(im(:,:,3)))/255; -edgeIm = sobel_mex(gray, 0.7); -im3 = repmat(edgeIm, [1 1 3]); -image(im3); \ No newline at end of file