mihaispr
Administrator
 Inregistrat: acum 17 ani
Postari: 2142
|
|
Continut script matlab (edges.m) - se poate alege din meniul language matlan in editorul de cod notepad++
% to apply edges image should be in grayscale %photos are stored in work folder of matlab
%image1
img1 = imread("photo1.jpg" );
% conversion to grayscale
img1_grey = rgb2gray(img1);
% now we apply extracting edges
[g1,t1] = edge(img1_grey,'sobel','horizontal'); imshow(g1); % display image using edge horizontal sobel operator for detecting edges
[g2,t2] = edge(img1_grey,'canny','horizontal'); figure, imshow(g2);
[g3,t3] = edge(img1_grey,'roberts','horizontal'); figure, imshow(g3);
[g4,t4] = edge(img1_grey,'sobel','vertical'); figure, imshow(g4); % display image using edge horizontal sobel operator for detecting edges
[g5,t5] = edge(img1_grey,'canny','vertical'); figure, imshow(g5);
[g6,t6] = edge(img1_grey,'roberts','vertical'); figure, imshow(g6);
%image2
img2 = imread("photo2.jpg" );
% conversion to grayscale
img2_grey = rgb2gray(img2);
% now we apply extracting edges
[g7,t7] = edge(img2_grey,'sobel','horizontal'); figure, imshow(g7); % display image using edge horizontal sobel operator for detecting edges
[g8,t8] = edge(img2_grey,'canny','horizontal'); figure, imshow(g8);
[g9,t9] = edge(img2_grey,'roberts','horizontal'); figure, imshow(g9);
[g10,t10] = edge(img1_grey,'sobel','vertical'); figure, imshow(g10); % display image using edge horizontal sobel operator for detecting edges
[g11,t11] = edge(img1_grey,'canny','vertical'); figure, imshow(g11);
[g12,t12] = edge(img1_grey,'roberts','vertical'); figure, imshow(g12);
% apply hough transform
H1 = hough(img1); figure, imshow(H1);
H2 = hough(img2); figure, imshow(H2);
photo1.jpg si photo2.jpg sunt numele pozelor.
Faceti un folder in care:
aveti un fisier edges_all.m cu continutul codului sursa de mai sus.
Puneti 2 imagini care le numiti photo1.jpg si photo2.jpg sau modificati in script functie de numele fotografiei.
|
|