MEDICAL-IMAGE-FILTER-CODE

The code allows users to input a scanned medical image file (e.g. tif, .jpeg )
20 Downloads
Updated 1 Sep 2023
This MATLAB script-file can applies several filters to a CT scan image of a patient to isolate and observe different tissues for lung cancer research. The program applies a 5x5 low pass filter, a 3x3 high pass filter, and a 3x3 edge detection filter to the original image. The filtered and unfiltered images are displayed in a figure with four subplots, including the original image, the smoothed image, the sharpened image, and the edge detection image. Additionally, an extra credit task is included, which removes pixels with intensities less than 200 and greater than 700 and displays the resulting image in a separate figure.
% Enter the Scanned Image File (e.g .tif,.jpeg)
image = imread('input'); % Please replace the 'input' with the image file.
% Display the original image
subplot(2, 2, 1);
imshow(image);
title('Original Image');
% Apply a 5X5 low pass filter to smoothen the image
Low_pass_filter = [1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;1,1,1,1,1]/5;
smoothed_image = conv2(Low_pass_filter, double(image));
% Display the smoothed image
subplot(2, 2, 2);
imshow(smoothed_image);
title('Smoothed Image');
% Apply a 3X3 high pass filter to sharpen the image
High_pass_filter = [-1,-1,-1;-1,9,-1;-1,-1,-1];
sharpened_image = conv2(smoothed_image, double(High_pass_filter));
% Display the sharpened image
subplot(2, 2, 3);
imshow(sharpened_image);
title('Sharpened Image');
% Apply an edge detection filter to detect the edges of the lungs
edge_detection_filter = [-1,-1,-1;-1,5,-1;-1,-1,-1];
edge_image = conv2(smoothed_image, double(edge_detection_filter));
% Display the edge detection image
subplot(2, 2, 4);
edge(edge_image);
title('Edge Detection Image');
% Display the color bar showing the intensity
colormap(gray);
colorbar;
% Remove pixels outside the range [200, 700]
removed_pixels_image = smoothed_image;
removed_pixels_image(removed_pixels_image < 200) = 0;
removed_pixels_image(removed_pixels_image > 700) = 0;
% Display the removed pixels image
figure;
imshow(removed_pixels_image);
title('Removed Pixels Image');
colormap(gray);
colorbar;

Cite As

Tobi Joshua Samuel (2024). MEDICAL-IMAGE-FILTER-CODE (https://github.com/Tobi-joshua/MEDICAL-IMAGE-FILTER-MATLAB-CODE/releases/tag/1.1.0), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0

See release notes for this release on GitHub: https://github.com/Tobi-joshua/MEDICAL-IMAGE-FILTER-CODE/releases/tag/1.1.0

1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.