Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. image = imread('SantaBarbara.jpg');
  2. imshow(image);
  3.  
  4. %%
  5. %find max and min for each color. min finds min of each row and turn it
  6. %into an array. use twice to find min of min arrays.
  7.  
  8. %Red
  9. minR = min(min(image(:,:,1)));
  10. maxR = max(max(image(:,:,1)));
  11. meanR = mean(mean(image(:,:,1)));
  12. %Green
  13. minG = min(min(image(:,:,2)));
  14. maxG = max(max(image(:,:,2)));
  15. meanG = mean(mean(image(:,:,2)));
  16. %Blue
  17. minB = min(min(image(:,:,3)));
  18. maxB = max(max(image(:,:,3)));
  19. meanB = mean(mean(image(:,:,3)));
  20. %%
  21. %display image size
  22.  
  23. [row,col,dim] = size(image);
  24. X = ['Image size: ', num2str(row), ' x ', num2str(col)];
  25. disp(X);
  26.  
  27. %%
  28. %displaying color info
  29.  
  30. %display Red
  31. X = ['Min, max R values: ', num2str(minR), ' ', num2str(maxR)];
  32. disp(X);
  33. %display Green
  34. X = ['Min, max G values: ', num2str(minG), ' ', num2str(maxG)];
  35. disp(X);
  36. %display Blue
  37. X = ['Min, max B values: ', num2str(minB), ' ', num2str(maxB)];
  38. disp(X);
  39. %display Avg
  40. X = ['Averages: ', num2str(meanR), ' ', num2str(meanG), ' ', num2str(meanB)];
  41. disp(X);
  42. %%
  43. %create rgb jpeg of intensities for each color
  44.  
  45. imwrite(image(:,:,1), 'TestRed.jpg');
  46. imwrite(image(:,:,2), 'TestGreen.jpg');
  47. imwrite(image(:,:,3), 'TestBlue.jpg');
  48. %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement