baseFileName = '1st_picture.png';
fullFileName = fullfile(folder, baseFileName);
errorMessage = sprintf('Error: file not found:\n%s', fullFileName)
uiwait(errordlg(errorMessage));
fprintf('Transforming image "%s" to a thermal image.\n', fullFileName);
rgbImage = imread(fullFileName);
h1 = imshow(rgbImage, []);
caption = sprintf('Original Pseudocolor Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
baseFileName = '1st_picture_colorbar.png';
fullFileName = fullfile(folder, baseFileName);
errorMessage = sprintf('Error: file not found:\n%s', fullFileName)
uiwait(errordlg(errorMessage));
colorBarImage = imread(fullFileName);
h2 = imshow(colorBarImage, []);
caption = sprintf('Cropped Colorbar Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
g.WindowState = 'maximized';
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
storedColorMap = colorBarImage(5:445, 19,:);
storedColorMap = double(squeeze(storedColorMap)) / 255;
storedColorMap = flipud(storedColorMap);
plot(storedColorMap(:, 1), 'r-', 'LineWidth', 3);
plot(storedColorMap(:, 2), 'g-', 'LineWidth', 3);
plot(storedColorMap(:, 3), 'b-', 'LineWidth', 3);
title('Stored Color Map', 'FontSize', fontSize);
indexedImage = rgb2ind(rgbImage, storedColorMap);
h4 = imshow(indexedImage, []);
caption = sprintf('Indexed Image (Gray Scale Thermal Image)');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
thermalImage = lowTemp + (highTemp - lowTemp) * mat2gray(indexedImage);
h5 = imshow(thermalImage, []);
hp = impixelinfo(gcf, [h1, h2, h4, h5]);
title('Floating Point Thermal (Temperature) Image', 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Column', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Row', 'FontSize', fontSize, 'Interpreter', 'None');
hp.Position = [0.45, 0.03, 0.25, 0.05];
histogram(thermalImage, 'Normalization', 'probability');
caption = sprintf('Histogram of Thermal Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Temperature [Degrees]', 'FontSize', fontSize, 'Interpreter', 'None');
ylabel('Frequency [Pixel Count]', 'FontSize', fontSize, 'Interpreter', 'None');
maxTemperature = max(thermalImage(:));
fprintf('The maximum temperature in the image is %.2f\n', maxTemperature);
fprintf('Done! Thanks Image Analyst!\n');