Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- total_images=20;
- ImageMatrixes=[];
- figure(1);
- for i=1:total_images
- str=strcat(int2str(i),'.bmp'); %creates string of photos filename
- eval('img=imread(str);'); % searches current folder for photo based on string
- subplot(ceil(sqrt(total_images)),ceil(sqrt(total_images)),i); %puts the image on a table based on the total images and the counter varible
- imshow(img);
- end
- figure(2);
- for i=1:total_images
- edge_det = edge(img,'canny');% apply edge detection to the image
- subplot(ceil(sqrt(total_images)),ceil(sqrt(total_images)),i);
- imshow(edge_det);
- drawnow;
- [imagerow, imagecollumn]=size(edge_det); % gets the number or rows and
- temp=reshape(edge_det',imagerow*imagecollumn,1); %creates a temporray matrix for the immage based on the size
- ImageMatrixes=[ImageMatrixes, temp]; %we then insert this into our image matrix
- end
- InputImage = input('Please enter the name of the image and its extension \n','s');
- InputImage = imread(strcat('C:\Users\Adam\Desktop\',InputImage)); % asks user to enter filename, combines it with desktop path
- InputImageMatrix = [];
- InputImageEdge = edge(InputImage, 'canny');
- [imagerowi, imagecollumni]=size(InputImage);
- temp=reshape(edge_det',imagerow*imagecollumn,1);
- InputImageMatrix = [InputImageMatrix, temp];
- figure(3);
- subplot(1,2,1);
- imshow(InputImage);
- subplot(1,2,2);
- imshow(InputImageEdge);
- distance = [];
- distance2 =[];
- for i =1:total_images
- [hd, D] = HausdorffDist(InputImageMatrix,ImageMatrixes(i));
- distance = [distance, hd];
- distance2 = [distance2, D];
- end
- Numberofhs = 1:size(distance,2);
- subplot(1,1,1)
- stem(Numberofhs,distance)
- title('Hausdorf distance of input image','fontsize',14)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement