SHARE
TWEET

Untitled

a guest Jun 16th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. colorImage = imread('1.jpg');
  2.  
  3.  
  4. R = colorImage(:, :, 1);
  5. G = colorImage(:, :, 2);
  6. B = colorImage(:, :, 3);
  7.  
  8. R = double(R);
  9. G = double(G);
  10. B = double(B);
  11. L = R + G + B;
  12. [H,W] = size(L)
  13. r = R./L;
  14. g = G./L;
  15.  
  16. r = int16(r*255)+1;
  17. g = int16(g*255)+1;
  18.  
  19.  
  20. h = zeros(256,256);
  21. for j=1:H
  22.     for i=1:W
  23.         wr = r(j,i);
  24.         wg = g(j,i);
  25.         h(wg,wr) = h(wg,wr)+1;
  26.     end
  27. end
  28. mesh(h)
  29. S=0;mi_r=0;mi_g=0;delta_rr=0;delta_gg=0;delta_rg=0;
  30. for j=1:256
  31.     for i=1:256
  32.         S=S+h(j,i);
  33.         mi_r=mi_r+h(j,i)*j;
  34.     end
  35. end
  36. mi_r=mi_r/S;
  37. for j=1:256
  38.     for i=1:256
  39.         mi_g=mi_g+h(j,i)*i;
  40.     end
  41. end
  42. mi_g=mi_g/S;
  43. for j=1:256
  44.     for i=1:256
  45.         delta_rr=delta_rr+h(j,i)*(j-mi_r)^2;
  46.     end
  47. end
  48. delta_rr=delta_rr/S;
  49. for j=1:256
  50.     for i=1:256
  51.         delta_gg=delta_gg+h(j,i)*(i-mi_g)^2;
  52.     end
  53. end
  54. delta_gg=delta_gg/S;
  55. for j=1:256
  56.     for i=1:256
  57.         delta_rg=delta_rg+h(j,i)*(j-mi_r)^2*(i-mi_g)^2;
  58.     end
  59. end
  60. delta_rg=delta_rg/S;
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