I need help for creating a point with 2x2 pixels , a line of 2x200 pixels and 256x256 solid square to produce a sinogram by using sinogram function.

3 visualizzazioni (ultimi 30 giorni)
Hello! I need help for creating a point with 2x2 pixels , a line of 2x200 pixels and 256x256 solid square to produce a sinogram by using sinogram function. I wrote the code for square down below:
%Creating the square image of 256x256 pixels
Image_sqr = zeros(256,256);
Image_sqr(128:129, 128:129) = 1;
imshow(Image_sqr);
title('Square Image')
%Radon transform for producing sinogram
theta=0:180;
imagesc(theta, 1:size(p,1), p);
%Sinogram
figure;
imagesc(theta, q, p);
title('Sinogram of a Square');
xlabel('Projection Angle Theta');
ylabel('Position');
colormap(hot);
colorbar;
I could not get a triangular sinusoidal image. I could not figure out what I am doing wrong and in addition to taht I don't know how to do this process with a point and a line. Could you please help me?

Risposta accettata

Tushar Sharma
Tushar Sharma il 13 Mar 2024
Hi Fatma,
Your code for creating a square and attempting to generate its sinogram is close, but it seems like you missed the actual Radon transform step. Here's the corrected complete code:
% Creating the square image of 256x256 pixels
Image_sqr = zeros(256,256);
Image_sqr(128:129, 128:129) = 1; % This creates a 2x2 square in the center
imshow(Image_sqr);
title('Square Image');
% Radon transform for producing sinogram
theta = 0:179; % 180 is unnecessary as 0 and 180 are the same due to symmetry
[R, xp] = radon(Image_sqr, theta);
% Displaying the sinogram
figure;
imagesc(theta, xp, R);
title('Sinogram of a Square');
xlabel('Projection Angle Theta');
ylabel('Position');
colormap(hot);
colorbar;
Similarly, a point can be represented by setting a single pixel to 1 in an otherwise zero matrix.
Also, a line can be created by setting a row or a column (or any arbitrary set of pixels) to 1.
Please refer to the below code for generating a sinogram for a line -
% Creating a line image of 256x256 pixels
Image_line = zeros(256,256);
Image_line(:,128:129) = 1; % This creates a vertical line of 2x200 pixels
imshow(Image_line);
title('Line Image');
% Radon transform for producing sinogram
[R_line, xp] = radon(Image_line, theta);
% Displaying the sinogram
figure;
imagesc(theta, xp, R_line);
title('Sinogram of a Line');
xlabel('Projection Angle Theta');
ylabel('Position');
colormap(hot);
colorbar;
The sinogram of a point will look like a sinusoidal line due to its projection at different angles, while the line and square will have different patterns based on their shapes and the angles of projection.
Hope it helps!

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by