Write a python code to create a sinogram for a given slice using the SheppLogan Phantom. Provide the following:
The code for generating the sinogram is organized into three classes
1.SquarePaddedImage.cs:
if (originalWidth > originalHeight) { // Width is greater than height; so we pad background pixels at the top and bottom // of the image, so that the original image comes in the middle of the square block PaddedWidth = originalWidth; PaddedHeight = originalWidth; InitializePaddedPixels(); int diff = (PaddedHeight - originalHeight) / 2; for (int i = diff * PaddedWidth; i < diff * PaddedWidth + originalWidth * originalHeight; ++i) { Pixels8PaddedRed[i] = pixels8OriginalRed[i - diff * PaddedWidth]; Pixels8PaddedGreen[i] = pixels8OriginalGreen[i - diff * PaddedWidth]; Pixels8PaddedBlue[i] = pixels8OriginalBlue[i - diff * PaddedWidth]; } }
2.ImageRotation.cs
This class has the responsibility of rotating a square image by a given angle. For example, if the rotation angle is specified as 3 degrees, this class can perform such a rotation, and give the resulting pixel array as an output. Additionally, it can also output back the resulting bitmap.
3.Sinogram.cs
// Populate the sinogram buffer for (int k = 0; k < numberOfAngles; ++k) { angleDegrees = -k; // Just watch the console for large images. // It should go on until 180. Console.Write(k + " "); ir.RotateImage(angleDegrees); pixels8RotatedRed = ir.Pixels8RotatedRed; pixels8RotatedGreen = ir.Pixels8RotatedGreen; pixels8RotatedBlue = ir.Pixels8RotatedBlue; for (int i = 0; i < SquareWidth; ++i) { sum = 0; index1 = i * numberOfAngles + k; for (int j = 0; j < SquareHeight; ++j) { index2 = j * SquareWidth + i; red = pixels8RotatedRed[index2]; green = pixels8RotatedGreen[index2]; blue = pixels8RotatedBlue[index2]; gray = red * 0.3 + green * 0.59 + blue * 0.11; gray /= maxsum; sum += gray; } sinogramValues[index1] = Math.Exp(-sum); } }
4.validation
-shape of the sinograms,and
-intensities of the sinograms
I1 = imread('Fig1.png'); I = rgb2gray(I1); theta = 0:180; [R,xp] = radon(I,theta); imagesc(theta,xp,R); colormap(gray);
Get Answers For Free
Most questions answered within 1 hours.