

Image taken from http://www.onlinetelemedicine.com/html/product/sam_images/X-Ray.jpg
As we can see in this histogram, the pixel values do not occupy the whole grayscale range(0-255). Instead, it is limited only the middle values of the grayscale, specifically 3-175.
To enhance this image, I need to backproject the image using the CDF of its histogram. The CDF of the image is shown below.

//SCILAB Code
imsize = size(image);
cy = cumsum(y);
cy = cy/max(cy); //normalized CDF y-value
for i = 1:imsize(1)
for j = 1:imsize(2)
index = find(x == image(i, j));
image(i,j) = cy(index);
end
end
//code end
After the backprojection, the image and its CDF are transformed as seen below.

The image after backprojection has a much better contrast and its CDF now looks like a straight line which extends from 0-255.
The next part of this activity was to use a nonlinear CDF to backproject the image. The main steps to do this was from x1(original value of the pixel), we find its corresponding y in its CDF (y1). y1 is then traced to the desired CDF (y2). And lastly, find the corresponding x value of y2 (x2).

//Scilab Code
imsize = size(image);
cy = cumsum(y);
cy = cy/max(cy);
scf(1);
plot(x, cy)
x = 0:255;
G = tanh(16.*(x-128)./255);
G = (G - min(G))./2;
scf(2);
plot(x, G)
for i = 1:imsize(1)
for j = 1:imsize(2)
index = find(x == image(i, j));
y1 = cy(index);
index2 = find(G <= y1);
image(i, j) = x(index2(max(index2)));
end
end
//code end
After the backprojection, the image and its CDF becomes:

The new CDF follows the tanh function.
For this activity I grade myself 10 because I was able to perform the required task and I worked independently.
No comments:
Post a Comment