fprintf('Beginning to run %s.m ...\n', mfilename);
baseFileName = 'color.jpg';
fullFileName = fullfile(folder, baseFileName);
fullFileNameOnSearchPath = baseFileName;
if ~exist(fullFileNameOnSearchPath, 'file')
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
fullFileName = fullFileNameOnSearchPath;
rgbImage = imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(rgbImage)
numberOfPixels = rows*columns;
caption = sprintf('RGB Image : "%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hFig1.Units = 'Normalized';
hFig1.WindowState = 'maximized';
[mask, maskedRGBImage] = createMask(rgbImage);
mask = bwareafilt(mask, 1);
mask = imfill(mask, 'holes');
maskedRgbImage = rgbImage .* cast(mask, 'like', rgbImage);
title('Skin Lesion Mask', 'FontSize', fontSize, 'Interpreter', 'None');
imshow(maskedRgbImage, []);
title('Masked Image', 'FontSize', fontSize, 'Interpreter', 'None');
lesionBoundary = bwboundaries(mask);
lab_Image = rgb2lab(rgbImage);
[lImage, aImage, bImage] = imsplit(lab_Image);
visboundaries(lesionBoundary);
title('L Channel', 'FontSize', fontSize);
visboundaries(lesionBoundary);
title('a Channel', 'FontSize', fontSize);
visboundaries(lesionBoundary);
title('b Channel', 'FontSize', fontSize);
[LMean, aMean, bMean] = GetMeanLABValues(lImage, aImage, bImage, mask);
bluegray = uint8([0 134 139]);
white= uint8([255 255 255]);
darkbrown = uint8([101 67 33]);
lightbrown = uint8([205 133 63]);
refLab_bg = rgb2lab(bluegray)
refLab_wh = rgb2lab(white)
refLab_bl = rgb2lab(black)
refLab_red = rgb2lab(red)
refLab_db = rgb2lab(darkbrown)
refLab_lbr = rgb2lab(lightbrown)
title('Original Image', 'FontSize',fontSize)
deImage_bg = GetDeltaEImage(lImage, aImage, bImage, refLab_bg);
visboundaries(lesionBoundary);
title('Delta E Blue Gray', 'FontSize',fontSize)
deImage_wh = GetDeltaEImage(lImage, aImage, bImage, refLab_wh);
visboundaries(lesionBoundary);
title('Delta E White', 'FontSize',fontSize)
deImage_bl = GetDeltaEImage(lImage, aImage, bImage, refLab_bl);
visboundaries(lesionBoundary);
title('Delta E Black', 'FontSize',fontSize)
deImage_red = GetDeltaEImage(lImage, aImage, bImage, refLab_red);
visboundaries(lesionBoundary);
title('Delta E Red', 'FontSize',fontSize)
deImage_db = GetDeltaEImage(lImage, aImage, bImage, refLab_db);
visboundaries(lesionBoundary);
title('Delta E Dark Brown', 'FontSize',fontSize)
deImage_lbr = GetDeltaEImage(lImage, aImage, bImage, refLab_lbr);
visboundaries(lesionBoundary);
title('Delta E Light Brown', 'FontSize',fontSize)
hFigDE.WindowState = "maximized";
meanDE_bg = mean(deImage_bg(mask))
meanDE_wh = mean(deImage_wh(mask))
meanDE_bl = mean(deImage_bl(mask))
meanDE_rd = mean(deImage_red(mask))
meanDE_db = mean(deImage_db(mask))
meanDE_lbr = mean(deImage_lbr(mask))
function deImage = GetDeltaEImage(lImage, aImage, bImage, refLAB)
deImage = sqrt((lImage - refLAB(1)).^2 + (aImage - refLAB(2)).^2 + (bImage - refLAB(3)).^2);
errorMessage = sprintf('Error running GetDeltaEImage:\n\n\nThe error message is:\n%s', ...
function [LMean, aMean, bMean] = GetMeanLABValues(LChannel, aChannel, bChannel, mask)
LVector = LChannel(mask);
aVector = aChannel(mask);
bVector = bChannel(mask);
errorMessage = sprintf('Error running GetMeanLABValues:\n\n\nThe error message is:\n%s', ...
function WarnUser(message)
function [BW,maskedRGBImage] = createMask(RGB)
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;