clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 18;
fprintf('Beginning to run %s.m ...\n', mfilename);
rgbImage = imread('flower.jpg');
rgbImage = imread('peppers.png');
[rows, columns, numberOfColorChannels] = size(rgbImage)
subplot(2, 2, 1);
imshow(rgbImage);
impixelinfo;
title('Original Color Image', 'FontSize', 20);
axis('on', 'image');
[x, y] = meshgrid(1:columns, 1:rows);
distanceImage = sqrt((x-columns/2).^2 + (y - rows/2).^2);
distanceImage = 1 - distanceImage / max(distanceImage(:));
yMid = int32(rows/2);
horizontalProfile = distanceImage(yMid, :);
subplot(2, 2, 3);
plot(horizontalProfile, 'b-', 'LineWidth', 2);
title('Horizontal Profile', 'FontSize', 20);
xlabel('Column', 'FontSize', 20);
ylabel('Attenuation Factor', 'FontSize', 20);
grid on;
if numberOfColorChannels == 3
distanceImage = cat(3, distanceImage, distanceImage, distanceImage);
end
subplot(2, 2, 2);
imshow(distanceImage, []);
yline(yMid, 'Color', 'b', 'LineWidth', 2);
impixelinfo;
axis('on', 'image');
title('Distance Image', 'FontSize', 20);
outputImage = uint8(distanceImage .* double(rgbImage));
subplot(2, 2, 4);
imshow(outputImage, []);
axis('on', 'image');
title('Output Image', 'FontSize', 20);
impixelinfo;
Best Answer