What does the Matlab fuction implement? function [R] = SomeFunction(img. theta.
ID: 3694863 • Letter: W
Question
What does the Matlab fuction implement? function [R] = SomeFunction(img. theta. thetaStep) %Obtain the image size in the x-direction [x, y] = size(img); %Set a matrix R to hold the projection data R = zeros((theta/thetaStep)+I,x): %Set vector for the angles to take projections at angles = 0:thetaStep:theta; %Matrix to hold all the rotated images separately to prevent blurring rotatedlmage = zeros(x, y,length(angles)); %Loop to rotate image and add up values for the projections for i = l:(length(angles)) %rotate the image starting with theta = 0 degrees rotatedlmage(:,:,i) = imrotate(img,angles(i).'nearest'. 'crop'); %Sum the columns of img to get projection data %Each row of R contains a projection at a certain theta R(i,:) = sum(rotatedImage(:.:.i).l): end %Convert the matrix to a gray scale image in the range 0 to 255 R = mat2gray(R): figure imshow(R) title('My SomeFunction') endExplanation / Answer
The Matlab function gives the following implementations
function [R] = RadonTransform(img, theta, thetaStep)
This function takes an image, theta max and theta step and returns a 2D matrix where each row is the projection of the original image at different angles by rotating the image and summing the pixels .
%Obtain the image size in the x-direction
[x,y] = size(img);
This function gives the information based on the image in x-direction with size of the image .some times it conatins the width and height.
%Set a matrix R to hold the projection data
R = zeros((theta/thetaStep)+1,x);
Initialize all the values that will be used by creating a steps x and theta step column matrix of zeros.
%Set vector for the angles to take projections at
angles = 0:thetaStep:theta;
This one is used for the vector the angles and to take the projections based on the angle .It also dependent on the thetastep and the theta values.
%Matrix to hold all the rotated images separately to prevent blurring
rotatedImage = zeros(x,y,length(angles));
In this it holds the values of images separately to avoid the blurring and patches .After that it rotate the image based on the angles and the length values which contains the matrix of zero values.
%Loop to rotate image and add up values for the projections
for i = 1:(length(angles))
It indicates to implement and rotate the image, and add the values for the projection of the images.
%rotate the image starting with theta = 0 degrees
rotatedImage(:,:,i) = imrotate(img,angles(i),'nearest', 'crop');
Rotate the image basedon the degree clockwise to bring it into better horizontal alignment. The example specified bilinear interpolation and requests that the result be cropped to be the same size as the original image.
%Each row of R contains a projection at a certain theta
R(i,:) = sum(rotatedImage(:,:,i),1);
A correction factor is calculated to the initial image so that the sum of the initial_image would match the sum of the sinogram
%Convert the matrix to a gray scale image in the range 0 to 255
R = mat2gray(R);
I = mat2gray(A,[amin amax]) converts the matrix A to the intensity image I. The returned matrix I contains values in the range 0 (black) to 1.0 (full intensity or white). amin and amax are the values in A that correspond to 0 and 1.0 in I. I = mat2gray(A) sets the values of amin and amax to the minimum and maximum values in A.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.