Advertisement
Guest User

Untitled

a guest
Dec 28th, 2015
13,655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.76 KB | None | 0 0
  1.  
  2. % Load and show image
  3. image = rgb2gray(imread('DfPMAaE.jpg'));
  4. imshow(image)
  5.  
  6. % Select and show region of interest
  7. BW = roipoly;
  8. close
  9. imROI = image.*uint8(BW);
  10. imshow(imROI)
  11.  
  12. % Set a pixel intensity threshold (because we're lazy)
  13. thresh = 90;
  14.  
  15. % Find contour of curve
  16. for indCol = 3:size(imROI,2)
  17.     if size(find(imROI(:,indCol)>thresh,1,'first'),1) == 1
  18.         x(indCol) = find(imROI(:,indCol)>thresh,1,'first');
  19.     else x(indCol) = NaN;
  20.     end
  21. end
  22. hold on, plot(x,'Color','w','LineWidth',2)
  23.  
  24. y = naninterp(x(10:end));
  25.  
  26. % Normalize waveform
  27. y = y - mean(y);
  28. y = (y - min(abs(y)))./(max(abs(y))-min(abs(y)));
  29. plot(y,'Color','k','LineWidth',2)
  30.  
  31. % Create sweet beautiful music
  32. sound(y,8000)
  33. filename = 'rain.wav';
  34. audiowrite(filename,y,Fs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement