SHARE
TWEET

RGB2rg

pabloducato Dec 1st, 2018 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function obraz_norma = RGB2rg(obraz)
  2.  
  3. rozmiar = size(obraz);
  4. if rozmiar(3) ~= 3,
  5.     error('Niepoprawny format obrazu');
  6. end;
  7. obraz_norma = zeros(rozmiar(1), rozmiar(2), 2);
  8. obraz_suma = double(obraz(:,:,1)) + double(obraz(:,:,2)) + double(obraz(:,:,3));
  9. maska = (obraz_suma == 0);
  10. obraz_norma(:,:,1) = double(obraz(:,:,1))./(obraz_suma+maska);
  11. obraz_norma(:,:,1) = obraz_norma(:,:,1).*(~maska);
  12. obraz_norma(:,:,2) = double(obraz(:,:,2))./(obraz_suma+maska);
  13. obraz_norma(:,:,2) = obraz_norma(:,:,2).*(~maska);
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