Convert Spectral Radiance to RGB for Animal Eyes
This function calculates the best-fit RGB values to make the color patches on a virtual stimulus look as color realistic as possible to another animal's visual system on an sRGB-calibrated display. This was originally written to accompany the paper:
Tedore C and Johnsen S. 2017. Using RGB displays to portray color realistic imagery to animal eyes. Current Zoology 63, 27-34, https://doi.org/10.1093/cz/zow076,
and has since been updated to accommodate any number of photoreceptor classes. Accompanying the m-file is a user input file called 'Spectral_Radiance_to_RGB_User_Spectra.xlsx' which the function reads and is essential to its functionality.
Upon running the function, the user will be prompted to input:
1. their study species' number of photoreceptor classes
2. the desired 0-255 level of the G phosphor for the background (sets the brightness of the background and can be tweaked over multiple runs to improve fit)
The function then reads the user input file. Into this file, the user must have inserted:
1. the spectral sensitivity of each of the study animal's photoreceptor classes
2. the radiance spectrum of each of the RGB display's phosphors
3. the background radiance spectrum to be simulated
4. the object color patch radiance spectra to be simulated
The best-fit b-factors and background and color patch RGB values will be printed in the command window and output as variables to the workspace.
bFactors = best-fit b-factors for each photoreceptor class (see Tedore & Johnsen 2017 for explanation)
backgrnd = best-fit RGB values for the background
colorPatches = best-fit RGB values for each color patch. Also shown for diagnostic purposes are the target and best obtained quantum catches for each photoreceptor class.
Bar charts showing the target versus best-fit quantum catches for each color patch will also be displayed.
If the animal has a UV photoreceptor class and the fit remains poor after tweaking the background brightness, the user should remove the UV photoreceptor class from the excel input file and re-run the function, specifying one fewer photoreceptor classes when prompted. The function will then calculate the best possible fit to the remaining photoreceptor classes.
For questions, please do not hesitate to contact the author directly or leave a comment below.
Cite As
Cynthia (2024). Convert Spectral Radiance to RGB for Animal Eyes (https://www.mathworks.com/matlabcentral/fileexchange/69853-convert-spectral-radiance-to-rgb-for-animal-eyes), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > 2-D and 3-D Plots > Surfaces, Volumes, and Polygons > Polygons >
- Sciences > Agriculture >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.