Programming/MATLAB

[MATLAB] Matlab Figure을 이용한 Zoom기능

BadaGreen_Kim 2019. 2. 20. 22:27


  1.  
  2.  
  3. Img1 = imread('peppers.png');
  4. Img1=imresize(Img1,[256 256]);
  5.  
  6. f=figure;
  7. imshow(Img1);
  8. rect = getrect(f); %//select roi with mouse
  9. Img1_roi = Img1( rect(2) : (rect(2)+rect(4)) , rect(1) : (rect(1)+rect(3)) , : ); %//store roi in matrix
  10.  
  11. Img2 = imread('coins.png');
  12. Img2= imresize(Img2,[256 256]);
  13.  
  14. f=figure;
  15. imshow(Img2);
  16. rect = getrect(f); %//select roi with mouse
  17. Img2_roi = Img2( rect(2) : (rect(2)+rect(4)) , rect(1) : (rect(1)+rect(3)) , : ); %//store roi in matrix
  18.  
  19. %//Plot
  20. subplot(2,2,1)
  21. imshow(Img1)
  22. subplot(2,2,2)
  23. imshow(Img2)
  24. subplot(2,2,3)
  25. imshow(Img1_roi)
  26. subplot(2,2,4)
  27. imshow(Img2_roi)