Hello, I need to take a color strip that gives concentration and convert it into a continuos quantitative graph that will give me RGB value vs concentration. The reference colorbar has 6 colors, which correspond to different concentrations. I need to
1 view (last 30 days)
Show older comments
Hello, I need to take a color strip that gives concentration and convert it into a continuous quantitative graph that will give me RGB value vs concentration. The reference colorbar has 6 colors, which correspond to different concentrations. I need to use matlab to convert the RGB values from each color to a graph, where if I know the RGB values of a picture I can determine the concentration. I have converted the reference colorbar to 100x600 pixel image where each color is a 100x100 pixel block that runs in a continuous fashion.
the concentration from left to right are 160,80,40,15,5,0 mg/ml If you could help that would be great.
3 Comments
Answers (1)
Image Analyst
on 14 Mar 2016
You need to get 6 mean RGB values. So split the image up into channels
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Then get the means
redMeans(1) = mean2(redChannel(:, 1:100));
redMeans(2) = mean2(redChannel(:, 101:200));
redMeans(3) = mean2(redChannel(:, 201:300));
redMeans(4) = mean2(redChannel(:, 301:400));
redMeans(5) = mean2(redChannel(:, 401:500));
redMeans(6) = mean2(redChannel(:, 501:end));
Then you can fit some polynomial through it
coefficients = polyfit(1:6, redMeans, 1); % Fit a line through them.
Now for any arbitrary concentration, you can get the estimated red value of it like:
estimatedRed = coefficients(1) * testConcentration + coefficients(2);
do the same for green and blue.
1 Comment
Image Analyst
on 14 Mar 2016
All this assumes that the color means lie along a straight line. If they don't you may have to increase the order of the polynomial. By the way, this is not how I'd really do it. And anyway, I'd do the converse. Usually you'd probably have an RGB color and you want to know the concentration, not vice versa like you asked.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!