Team:SJTU-BioX-Shanghai/Color Chart

Color Chart
Color Chart

We developed a tool which could create a inducer-color matching chart. This color chart could be either stored in our mobile APP or printed as a convenient inducer-color matching tool, by which we could easily quantify two kinds of inducers at the same time. This tool was developed in MATLAB by utilizing image processing methods.

Mechanism

1.Read an image.

2.Find standard area center.

3.Calculate standard area RGB sperately.

4.Make a gradient color figure by linear interpolation.

Matlab Code

%initialize

close all

clc

RGB = imread( 'test.jpg' );

ion1='As'; ion2='IPTG';

ion1concentration=[0,0.2,0.4]; ion2concentration=... [0,0.1,0.2];

ion1num=size(ion1concentration,2);

ion2num=size(ion2concentration,2);

fprintf('%s have %.0f ranks,%s have %.0f\n ranks',ion1,ion1num,ion2,ion2num)

%% mark standard area, calculate RGB and output ion1num*ion2num matrix

R = im2double(RGB( :, :, 1 ));

G = im2double(RGB( :, :, 2 ));

B = im2double(RGB( :, :, 3 ));

StandardArea = [200,200,100;500,200,100;800,200,100;...

200,500,100;500,500,100;800,500,100;...

200,800,100;500,800,100;800,800,100];

% marker = insertShape(RGB,'circle',StandardArea,'LineWidth',5 ,...

% 'Color', 'red','Opacity',0.7) %mark

[m,n]=size(StandardArea);

StandardRadius=StandardArea(1,3);

StandardCenter=StandardArea(:,1:2);

AverageR=zeros(m,1);AverageG=zeros(m,1);AverageB=zeros(m,1);

for i=1:m %For every area

k=0;AllR=0;AllG=0;AllB=0;

for x=(StandardCenter(i,1)-StandardRadius):(StandardCenter(i,1)+StandardRadius)

for y=(StandardCenter(i,2)-StandardRadius):(StandardCenter(i,2)+StandardRadius)

if sqrt((x-StandardCenter(i,1))^2+(y-StandardCenter(i,2))^2)

AllR = AllR + R(x,y);

AllG = AllG + G(x,y);

AllB = AllB + B(x,y);

k=k+1;

end

end

end

AverageR(i) = AllR/k;

AverageG(i) = AllG/k;

AverageB(i) = AllB/k;

end

%% Print Standard Color Chart

AverageR=im2uint8(AverageR);

AverageG=im2uint8(AverageG);

AverageB=im2uint8(AverageB);

reshape(AverageR,ion1num,ion2num)

reshape(AverageG,ion1num,ion2num)

reshape(AverageB,ion1num,ion2num)

Im(:,:,1)=AverageR;

Im(:,:,2)=AverageG;

Im(:,:,3)=AverageB;

I=imresize(RGB,[1080 1920]);

imshow(I);

Figure1: Color Chart MakingAfter taking photo and image processing,we get a gradient figure.