www.gusucode.com > GUI界面设计范例和ppt资料电信课程设计 > GUI界面设计范例和ppt资料电信课程设计/GUI界面设计范例/电信课程设计/5.compression/rgb22hsi.m
function [hsi,H,S,I] = rgb22hsi(rgb) % Extract the individual component immages. rgb = im2double(rgb); r = rgb(:, :, 1); g = rgb(:, :, 2); b = rgb(:, :, 3); % Implement the conversion equations. num = 0.5*((r - g) + (r - b)); den = sqrt((r - g).^2 + (r - b).*(g - b)); theta = acos(num./(den + eps)); H = theta; H(b > g) = 2*pi - H(b > g); H = H/(2*pi); num = min(min(r, g), b); den = r + g + b; den(den == 0) = eps; S = 1 - 3.* num./den; H(S == 0) = 0; I = (r + g + b)/3; % Combine all three results into an hsi image. hsi = cat(3, H, S, I);