Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.89 KB | None | 0 0
  1. total_images=20;
  2. ImageMatrixes=[];  
  3.  
  4.  
  5. figure(1);
  6. for i=1:total_images
  7.     str=strcat(int2str(i),'.bmp'); %creates string of photos filename
  8.     eval('img=imread(str);'); % searches current folder for photo based on string
  9.     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
  10.     imshow(img);
  11.                        
  12. end
  13.  
  14. figure(2);
  15. for i=1:total_images
  16.     str=strcat(int2str(i),'.bmp'); %creates string of photos filename
  17.     eval('img=imread(str);'); % searches current folder for photo based on string
  18.     edge_det = edge(img,'sobel');% apply edge detection to the image
  19.     subplot(ceil(sqrt(total_images)),ceil(sqrt(total_images)),i);
  20.     imshow(edge_det);
  21.     drawnow;
  22.     [imagerow, imagecollumn]=size(edge_det);    % gets the number or rows and
  23.     temp=reshape(edge_det',imagerow*imagecollumn,1);     %creates a temporray matrix for the immage based on the size
  24.     ImageMatrixes=[ImageMatrixes, temp];         %we then insert this into our image matrix
  25. end
  26.  
  27. InputImage = input('Please enter the name of the image and its extension \n','s');
  28. InputImage = imread(strcat('C:\Users\Adam\Desktop\',InputImage)); % asks user to enter filename, combines it with desktop path
  29. InputImageMatrix = [];
  30. InputImageEdge = edge(InputImage, 'sobel');
  31. [imagerowi, imagecollumni]=size(InputImage);
  32. temp=reshape(edge_det',imagerow*imagecollumn,1);
  33. InputImageMatrix = [InputImageMatrix, temp];
  34. figure(3);
  35. subplot(1,2,1);
  36. imshow(InputImage);
  37. subplot(1,2,2);
  38. imshow(InputImageEdge);
  39.  
  40. distance = [];
  41. distance2 =[];
  42. for i =1:total_images
  43.     [hd, D] = HausdorffDist(InputImageMatrix,ImageMatrixes(i));
  44.     distance = [distance, hd];
  45.     distance2 = [distance2, D];
  46. end
  47.  
  48. Numberofhs = 1:size(distance,2);
  49. subplot(1,1,1)
  50. stem(Numberofhs,distance)
  51. title('Hausdorf distance of input image','fontsize',14)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement