Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function obraz_norma = RGB2rg(obraz)
- rozmiar = size(obraz);
- if rozmiar(3) ~= 3,
- error('Niepoprawny format obrazu');
- end;
- obraz_norma = zeros(rozmiar(1), rozmiar(2), 2);
- obraz_suma = double(obraz(:,:,1)) + double(obraz(:,:,2)) + double(obraz(:,:,3));
- maska = (obraz_suma == 0);
- obraz_norma(:,:,1) = double(obraz(:,:,1))./(obraz_suma+maska);
- obraz_norma(:,:,1) = obraz_norma(:,:,1).*(~maska);
- obraz_norma(:,:,2) = double(obraz(:,:,2))./(obraz_suma+maska);
- obraz_norma(:,:,2) = obraz_norma(:,:,2).*(~maska);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement