clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 20;
[rgbImage, colorMap] = imread('football.jpg');
subplot(2, 3, 1);
imshow(rgbImage, colorMap);
axis on;
title('Original Color Image', 'FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
grayImage = rgbImage(:, :, 1);
subplot(2, 3, 2);
imshow(grayImage, colorMap);
axis on;
title('Red Channel Image', 'FontSize', fontSize);
theta = 0:180;
[R,xp] = radon(grayImage,theta);
maxR = max(R(:));
[rowOfMax, columnOfMax] = find(R == maxR)
h3 = subplot(2, 3, [3,6]);
imshow(R,[],'Xdata',theta,'Ydata',xp,...
'InitialMagnification','fit')
axis on;
hold on;
plot(h3, columnOfMax, xp(rowOfMax), 'bo', 'MarkerSize', 30, 'LineWidth', 3);
line([columnOfMax, columnOfMax], [xp(end), xp(rowOfMax)+15], 'Color', 'b', 'LineWidth', 3);
caption = sprintf('Radon Transform. Max at angle %.1f', columnOfMax);
title(caption, 'FontSize', fontSize);
xlabel('\theta (degrees)', 'FontSize', fontSize)
ylabel('x''', 'FontSize', fontSize)
colormap(h3, hot(256));
colorbar;
rotatedImage = imrotate(rgbImage, -columnOfMax);
subplot(2, 3, 4);
imshow(rotatedImage);
axis on;
title('Rotated Color Image', 'FontSize', fontSize);
rotatedImage = imrotate(rgbImage, -columnOfMax+90);
subplot(2, 3, 5);
imshow(rotatedImage);
axis on;
title('Rotated Color Image', 'FontSize', fontSize);
Best Answer