SHARE
TWEET

Untitled

a guest Sep 11th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clc
  2. clear
  3.  
  4. filePath = 'D:\Desktop\ENGGEN 131\MATLAB Project\SuppliedCode\lunar';
  5. extension = 'jpg';
  6. filenames = GenerateImageList(filePath, extension);
  7. imageList = ReadImages(filePath, filenames);
  8.  
  9. tic
  10.  
  11.  
  12. imageMedian = double(RemoveAction(imageList));
  13. imageStacked = double(cat(4,imageList{:}));
  14. distanceArray = zeros(size(imageMedian, 1), size(imageMedian, 2), size(imageStacked, 4));
  15.  
  16.  
  17.  
  18. for i = 1:size(imageStacked,4)
  19.     distanceArray(:,:,i) = (imageMedian(:,:,1) - imageStacked(:,:,1,i)).^2 +...
  20.     (imageMedian(:,:,2) - imageStacked(:,:,2,i)).^2 + ...
  21.     (imageMedian(:,:,3) - imageStacked(:,:,3,i)).^2;
  22. end
  23.  
  24.  
  25. [~, maxPostion] = max(distanceArray,[],3);
  26.  
  27. [rows, cols, colours] = ndgrid(1:size(imageStacked,1), 1:size(imageStacked,2), 1:3);
  28.  
  29. maxPositionColour = repmat(maxPostion, 1, 1, 3);
  30. colourLinearPosition = sub2ind(size(imageStacked), rows, cols, colours, maxPositionColour);
  31. finalImage = uint8(imageStacked(colourLinearPosition));
  32.  
  33. toc
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top