% Recreates variables (colorR, colorG, colorB)
load colorRGB

% 320, 640, 1024, 1280
imageWidth = 1024;
imageHeight = imageWidth * 0.75;

outerWidth = round(imageWidth/2/ 7)*2;
outerOffset = round(imageWidth/2/ 9)*2;

innerWidth = round(imageWidth/2/ 10)*2;

imageR = ones(imageHeight, imageWidth);
imageG = imageR;
imageB = imageR;

for backgroundWavelength = 430:15:730
index = backgroundWavelength-430+1;

imageR(:,:) = colorR(1,index);
imageG(:,:) = colorG(1,index);
imageB(:,:) = colorB(1,index);

for targetWavelength = 430+5:25:730
index = targetWavelength-430+1;

% Upper Left Corner
imageR(outerOffset:outerOffset+outerWidth,outerOffset:outerOffset+outerWidth) = colorR(1,index);
imageG(outerOffset:outerOffset+outerWidth,outerOffset:outerOffset+outerWidth) = colorG(1,index);
imageB(outerOffset:outerOffset+outerWidth,outerOffset:outerOffset+outerWidth) = colorB(1,index);

%Lower Left Corner
imageR(imageHeight-outerOffset-outerWidth:imageHeight-outerOffset,outerOffset:outerOffset+outerWidth) = colorR(1,index);
imageG(imageHeight-outerOffset-outerWidth:imageHeight-outerOffset,outerOffset:outerOffset+outerWidth) = colorG(1,index);
imageB(imageHeight-outerOffset-outerWidth:imageHeight-outerOffset,outerOffset:outerOffset+outerWidth) = colorB(1,index);

% Upper Right Corner
imageR(outerOffset:outerOffset+outerWidth,imageWidth-outerOffset-outerWidth:imageWidth-outerOffset) = colorR(1,index);
imageG(outerOffset:outerOffset+outerWidth,imageWidth-outerOffset-outerWidth:imageWidth-outerOffset) = colorG(1,index);
imageB(outerOffset:outerOffset+outerWidth,imageWidth-outerOffset-outerWidth:imageWidth-outerOffset) = colorB(1,index);

% Lower Right Corner
imageR(imageHeight-outerOffset-outerWidth:imageHeight-outerOffset,imageWidth-outerOffset-outerWidth:imageWidth-outerOffset) = colorR(1,index);
imageG(imageHeight-outerOffset-outerWidth:imageHeight-outerOffset,imageWidth-outerOffset-outerWidth:imageWidth-outerOffset) = colorG(1,index);
imageB(imageHeight-outerOffset-outerWidth:imageHeight-outerOffset,imageWidth-outerOffset-outerWidth:imageWidth-outerOffset) = colorB(1,index);

% Center
% 595
imageR(0.5*imageHeight-0.5*innerWidth:0.5*imageHeight+0.5*innerWidth,0.5*imageWidth-0.5*innerWidth:0.5*imageWidth+0.5*innerWidth) = colorR(1,index);
imageG(0.5*imageHeight-0.5*innerWidth:0.5*imageHeight+0.5*innerWidth,0.5*imageWidth-0.5*innerWidth:0.5*imageWidth+0.5*innerWidth) = colorG(1,index);
imageB(0.5*imageHeight-0.5*innerWidth:0.5*imageHeight+0.5*innerWidth,0.5*imageWidth-0.5*innerWidth:0.5*imageWidth+0.5*innerWidth) = colorB(1,index);

i = 1:256;
iMonitorGama = (i/256).^(1/1.495);

imageRg = iMonitorGama(round(imageR*255)+1);
imageGg = iMonitorGama(round(imageG*255)+1);
imageBg = iMonitorGama(round(imageB*255)+1);

[X map] = rgb2ind(imageR, imageG, imageB, 256);
%imshow(X, map);
imwrite(X, map, ['centerYes/input' num2str(backgroundWavelength) '-' num2str(targetWavelength) '.bmp'], 'bmp')

[X map] = rgb2ind(imageRg, imageGg, imageBg, 256);
imwrite(X, map, ['centerYesG/input' num2str(backgroundWavelength) '-' num2str(targetWavelength) '.bmp'], 'bmp')

end
end
