xinyabo体育

Image processing concepts, algorithms, and MATLAB

Making Color Spectrum Plots – Part 1

The new edition ofDigital Image Processing Using MATLAB(DIPUM3E) contains a number of MATLAB functions related to color, color calculations, and color visualization. I wrote about functions for displaying color swatches in myMarch 10 post. You can find some of the functions inMATLAB Color Toolson the File Exchange, as well as in theGitHub repositorycontaining the MATLAB source code for the book.

A MathWorks friend asked me, earlier this year, why I chose to write the specific color-related functions that I did. The answer is that I wrote the functions that would help tell the story I wanted to tell. For example, I wanted to talk early in the chapter about the interactions between illumination, object reflectance, and the color sensitivity of retinal receptors in the eye. To help with that story, I wanted to include plots likeDIPUM3EFigure 7.2(a):

I thought I would give you a tour of the various algorithms and functions that went into making this and similar plots, including:

  • MATLAB functionsreadtable,interp1,conv2,linspace,colorbar
  • Image Processing Toolbox functionsxyz2rgb,lin2rgb
  • DIPUM3Efunctionsilluminant,lambda2xyz,colorMatchingFunctions,spectrumColors,spectrumBar

I expect the tour to take a couple more blog posts.

First, where does the data in the plot come from? The curve is called a relative spectral power distribution curve. This particular curve is for a standardilluminantcalled D65, which is intended to approximate average mid-day daylight. The curve is a reference curve created by theInternational Commission on Illumination, usually written asCIEfor the French acronym.

I could have provided this standard data in a MAT-file, I suppose, but I chose instead to provide it as a spreadsheet file, Illuminants.xlsx. Here's what it looks like:

Along the bottom, you can see that the file contains several sheets: D50, D55, D65, D75, A, C, and F7. These sheets contain the data for different types of illuminants.

My tool of choice for reading an Excel file like this isreadtable. In the call below, I indicate that I don't wantreadtableto invoke Excel (this is now the default behavior), and I also indicate that I want to read the D65 sheet.

T = readtable('Illuminants.xlsx','UseExcel',false,'Sheet','D65');

TheDIPUM3Efunctionilluminantis basically just this call toreadtable.

And here's what the resulting MATLAB table looks like:

head(T)
ans = 8×2 table lambda S ______ ______ 300 0.0341 305 1.6643 310 3.2945 315 11.765 320 20.236 325 28.645 330 37.053 335 38.501

I can produce a basic plot like this:

plot(T.lambda,T.S) xlabel('wavelength (nm)') ylabel('Relative spectral power') title('Illuminant D65')

Next time, I'll talk about computing the rainbow colors that appear at the bottom ofDIPUM3EFigure 7.2(a):




Published with MATLAB® R2020a

|
  • print
  • send email

Comments

To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.