ConversionHSIaRGB(I​mg)

conversion imagen HSI a RGB
34 Downloads
Updated 4 Apr 2016

View License

Con este codigo se puede convertir una imagen SHI a RGB..
function RGB1=ConversionHSIaRGB(Img)
%%Se obtiene la tonalidad(H),la saturacion(S), y la intensidad(I)
H=Img(:,:,1);
S=Img(:,:,2);
I=Img(:,:,3);
H=H*360; %multiplicar para obtener un angulo de H en un rango de [0 360]

%%Se asignan los componentes de RGB
R=zeros(size(H));
G=zeros(size(H));
B=zeros(size(H));
RGB=zeros([size(H),3]);

%Sector RG (0 <= H < 120)
B(H<120)=I(H<120).*(1-S(H<120));
R(H<120)=I(H<120).*(1+((S(H<120).*cosd(H(H<120)))./cosd(60-H(H<120))));
G(H<120)=3.*I(H<120)-(R(H<120)+B(H<120));

%Sector GB (120 <= H < 240)
H2=H-120; %Restar 120 grados al angulo de H

R(H>=120&H<240)=I(H>=120&H<240).*(1-S(H>=120&H<240));
G(H>=120&H<240)=I(H>=120&H<240).*(1+((S(H>=120&H<240).*cosd(H2(H>=120&H<240)))./cosd(60-H2(H>=120&H<240))));
B(H>=120&H<240)=3.*I(H>=120&H<240)-(R(H>=120&H<240)+G(H>=120&H<240));

%Sector BR (240 <= H <= 360)
H2=H-240; %Restar 240 grados al angulo de H

G(H>=240&H<=360)=I(H>=240&H<=360).*(1-S(H>=240&H<=360));
B(H>=240&H<=360)=I(H>=240&H<=360).*(1+((S(H>=240&H<=360).*cosd(H2(H>=240&H<=360)))./cosd(60-H2(H>=240&H<=360))));
R(H>=240&H<=360)=3.*I(H>=240&H<=360)-(G(H>=240&H<=360)+B(H>=240&H<=360));

%Obtener el RGB
RGB(:,:,1)=R;
RGB(:,:,2)=G;
RGB(:,:,3)=B;

RGB1 =RGB;

Cite As

juan david castaño (2026). ConversionHSIaRGB(Img) (https://www.mathworks.com/matlabcentral/fileexchange/56334-conversionhsiargb-img), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.0.0.0