File Exchange

image thumbnail

HSI <-> RGB Image Conversion Tools

version (3.22 KB) by DGM
Convert RGB images to HSI and back


Updated 19 Oct 2020

View Version History

View License

RGB2HSI() and HSI2RGB() were created in response to a bug in the popular conversion tool COLORSPACE(). I have not been able to contact the author of COLORSPACE(), so I'm submitting this to fill the gap.
The bug mentioned results in HSI transformations incorrectly being handled as HSL transformations. This problem exists only when using the M-code version of COLORSPACE(); if COLORSPACE() is compiled as a MEX function, the implementations are correct. For anyone who can't compile MEX functions for whatever reason, RGB2HSI() and HSI2RGB() may suffice.
The output range for the HSI image matches what COLORSPACE() would produce.

Cite As

DGM (2020). HSI <-> RGB Image Conversion Tools (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)


Juan: I see from your recent submission that you went ahead and forged your own solution. Sorry for my lack of prompt helpfulness.


Juan: P.S. Maybe it's bad form, but I capitalize function names for emphasis in the documentation; otherwise, if that's how you were using em, case-sensitivity will result in errors. 2009b tries to auto-match case-insensitively and produces warnings, but i have no idea what newer versions do.

juan david castaño

La versión que tengo de matlab es R2015a y no me funciona, lo estoy así eso así: en una función de mando la imagen HSI la cual estaba en RGB, la idea era tomar una imagen RGB y pasarla a HSI, y mirar los canales por aparte, eso lo hice con la ayuda de un código que está publicado por alguien acá mismo en la comunidad, ahora lo que necesito es pasar la imagen resultante nuevamente ósea la imagen HSI a RGB, pero me sale el error " undefined function or variable 'HSI2RGB', lo estoy adié si así : RGB= HSI2RGB(hsi);

Hay alguna manera de hacerlo por código?
Muchas gracias por su importante ayuda.

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Colorspace Transformations

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!