% % function [colors, debugImage] = getMacbethColors(image, upperLeftCenter, % patchSize, windowSize ) % % Input: image: the camera image of the macbeth color checker % upperLeftCenter: the center of the brown patch in (row, col) form % the origin is the upper-left corner % patchSize: a scalar indicates the size of the patches % windowSize: the size of the average windows % % Return: colors: a 3x24 matrix of the 24 colors in row major ordering % debugImage: the debug image % function [colors, debugImage] = getMacbethColors(image,upperLeftCenter,patchSize,windowSize) debugImage = uint8(image); image = double(image); if(nargin == 1) upperLeftCenter = [80 80]; patchSize = 95; windowSize = 20; end white = [255 255 255]; halfWindowSize = windowSize/2; windowSize = halfWindowSize*2+1; colors = zeros(3,24); for row=1:4 for col=1:6 center_row = upperLeftCenter(1) + (row-1)*patchSize; center_col = upperLeftCenter(2) + (col-1)*patchSize; patchColor = [0 0 0]'; for i=(center_row-halfWindowSize):(center_row+halfWindowSize) for j=(center_col-halfWindowSize):(center_col+halfWindowSize) patchColor(1) = patchColor(1) + image(i,j,1); patchColor(2) = patchColor(2) + image(i,j,2); patchColor(3) = patchColor(3) + image(i,j,3); debugImage(i,j,:) = white; end end colors(:, (row-1)*6+col) = patchColor/(windowSize*windowSize); end end % sony % upperLeftCenter = [80, 80] % patchSize = 95 % olympus % upperLeftCenter = [80, 80] % patchSize = 95