-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdgeDetection.m
More file actions
53 lines (29 loc) · 1.05 KB
/
EdgeDetection.m
File metadata and controls
53 lines (29 loc) · 1.05 KB
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
52
% Initialize a list to store the image data
images = cell(1, nfiles);
% Read each image and store it in the list
for ii = 1:nfiles
currentfilename = fullfile(img_dir, imagefiles(ii).name);
currentimage = imread(currentfilename);
% Convert the image to grayscale if it's color
if size(currentimage, 3) == 3
currentimage = rgb2gray(currentimage);
end
% Perform histogram equalization
equalized_image = histeq(currentimage);
% Apply Canny edge detection
edges = edge(equalized_image, 'Canny', [0.1 0.3]); % You can adjust the thresholds as needed
% Display the original image and the edges
figure;
subplot(1, 2, 1);
imshow(image_matrix);
title('Histogram equalized image');
axis off;
subplot(1, 2, 2);
imshow(edges);
title('Edges (Canny)');
axis off;
% Save the edge-detected image
imwrite(edges, 'xray_edges.jpg');
disp('Edge-detected image saved as xray_edges.jpg');
images{ii} = currentimage;
end