MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by Aissa on 19 May 2013

How to calculate I looked at how the rotation does not change the results of the calculation for the medium point, but I have not found the same results! I do not know if my program is wrong or not? The program is simple:

image = imread('lena.bmp'); I=rgb2gray(image);

theta= 0:1:179; [R,xp]= radon(I,theta); [n,l]=size(R);

% calculate the medium point n1=floor(n/2);

% take the medium points of original image points=R(n1,1:1:180); II=imrotate(I,2); % rotation de 2° R_rotation= radon(II,theta);

% take the medium points after rotation Points_après_rotation = R_rotation(n1,1:1:180);

thank you

Answer by Image Analyst on 19 May 2013

Accepted answer

I'm finding a difference. Run my demo. It's based on yours but I cleaned it up a bit to be far more illustrative, and I used a standard demo image.

clc; clearvars; close all; workspace; fontSize = 16;

% Read in a standard MATLAB gray scale demo image. folder = fullfile(matlabroot, '\toolbox\images\imdemos'); if ~exist(folder, 'dir') % If that folder does not exist, don't use a folder % and hope it can find the image on the search path. folder = []; end baseFileName = 'cameraman.tif'; fullFileName = fullfile(folder, baseFileName); grayImage = imread(fullFileName); % Get the dimensions of the image. numberOfColorBands should be = 1. [rows, columns, numberOfColorBands] = size(grayImage) % Display the original gray scale image. subplot(3, 3, 1); imshow(grayImage, []); title('Original Grayscale Image', 'FontSize', fontSize); % Enlarge figure to full screen. set(gcf, 'units','normalized','outerposition',[0 0 1 1]);

% Compute Radon Transform. theta= 0:1:179; [R,xp]= radon(grayImage,theta); [n,l]=size(R); subplot(3, 3, 2); imshow(R, []); title('R Image', 'FontSize', fontSize);

% Determine the middle row. middleRow = floor(n/2);

% Extract and plot the middle row after rotation. points=R(middleRow, 1 : 180); subplot(3, 3, 3); plot(points, 'b+-'); title('points', 'FontSize', fontSize);

% Rotate the image by 2 degrees. rotatedImage = imrotate(grayImage,2); % rotation de 2° % Display the original gray scale image. subplot(3, 3, 4); imshow(rotatedImage, []); title('Rotated Grayscale Image', 'FontSize', fontSize);

% Compute Radon Transform. R_rotation = radon(rotatedImage,theta); subplot(3, 3, 5); imshow(R_rotation, []); title('R rotation Image', 'FontSize', fontSize);

% Extract and plot the middle row after rotation. Points_apres_rotation = R_rotation(middleRow,1 : 180); subplot(3, 3, 6); plot(R_rotation, 'b+-'); title('Points apres rotation', 'FontSize', fontSize);

% Construct difference between middle rows. diffPoints = points - Points_apres_rotation; subplot(3, 3, 8); plot(diffPoints, 'b+-'); title('Difference between rows', 'FontSize', fontSize);

Aissa on 19 May 2013

Well which points of Radon transform of an image are invariant to rotation or scale??? I am looking about this. thanks

Image Analyst on 19 May 2013

The center of rotation should be. But you didn't look at that, and you have to be careful about scaling. It's not invariant to scale, unless it somehow normalizes it internally but I didn't see that mentioned. So if an image is twice as big, the Radon transform values should be twice as great, because you're summing twice as many pixels.

## 0 Comments