Advertisement
makispaiktis

Tutorial Thomas - Change Lena Image

Aug 10th, 2021 (edited)
1,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.70 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. % MAIN FUNCTION
  5. A = imread('lena.png');
  6. [M, N, rgb] = size(A);
  7. limit1 = -50;
  8. limit2 = 50;
  9.  
  10. offset = 0
  11. A2 = changeLenaImage(A, M, N, limit1, limit2);
  12. A3 = changeLenaImage(A, M, N, limit1, limit2);
  13. A4 = changeLenaImage(A, M, N, limit1, limit2);
  14. % Concatenate 3D objects = images
  15. figure();
  16. A_array = cat(4, A, A2, A3, A4);
  17. montage(A_array);
  18.  
  19. % Auxiliary Function
  20. function A_new = changeLenaImage(A, M, N, limit1, limit2)
  21.     offset = randi([limit1 limit2])
  22.     for i = 1:M
  23.         for j = 1:N
  24.             A_new(i, j, 1) = A(i, j, 1) + offset;
  25.             A_new(i, j, 2) = A(i, j, 2) + offset;
  26.             A_new(i, j, 3) = A(i, j, 3) + offset;
  27.         end
  28.     end
  29.     A_new;
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement