-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_image.m
51 lines (39 loc) · 1.13 KB
/
single_image.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
clear all;
clc;
close all;
I = imread('Dataset/img12.JPG');
I=imresize(I,[500 500]);
% gaussian filtered image and grayscaling
I=rgb2gray(I);
J=imgaussfilt(I,0.5);
figure('name','Original Image');imshow(I);
% apply canny's algorithm for edge extraction
iterthreshold=iter_threshold(J);
figure('name','Iterative Thresholding');imshow(iterthreshold);
%complementing image
I=imcomplement(iterthreshold);
figure('name','Complemented');imshow(I);
I=imclearborder(I);
figure('name','Lung border removed');imshow(I);
I=imfill(I,'holes');
PT1=I;
figure('name','Holes filled image');imshow(I);
I=immultiply(J,I);
figure('name','Mapped with input image');imshow(I);
I=adapthisteq(I);
level = graythresh(I);
I = imbinarize(I,level);
figure('Name','Otsu Thresholded image'),imshow(I);
I=imcomplement(I);
figure('name','Complement of otsu threshold');imshow(I);
PT2=I;
K=immultiply(PT1,PT2);
figure('name','Mapping of PT1 and PT2');imshow(K);
I=ExtractNLargestBlobs(K,1);
SE=strel('square',2);
I=imclose(I,SE);
I=imfill(I,'holes');
figure('name','Small pieces are removed and closed');imshow(I);
ROI=I;
I=immultiply(I,J);
figure('name','ROI');imshow(I);