-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.m
More file actions
105 lines (90 loc) · 2.98 KB
/
main.m
File metadata and controls
105 lines (90 loc) · 2.98 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
directory="./images/"
% import_display_images(directory);
% ===== resize image=======:
function image_resize()
filename = './images/Tomato___Bacterial_spot.JPG';
new_width = 50;
original_img = imread(filename);
resized_img = resize_image(original_img, new_width);
display_images(original_img, resized_img);
end
% ====== grayscale_conversion==========
function gray_scale_test()
% Display original and grayscale images
filename = './images/Tomato___Bacterial_spot.JPG';
rgb_img = imread(filename);
% Call grayscale conversion functions
gray_avg = grayscale_average(rgb_img);
gray_lum = grayscale_luminosity(rgb_img);
gray_des = grayscale_desaturation(rgb_img);
figure;
subplot(2, 2, 1);
imshow(rgb_img);
title('Original Image');
subplot(2, 2, 2);
imshow(gray_avg);
title('Grayscale (Average Method)');
subplot(2, 2, 3);
imshow(gray_lum);
title('Grayscale (Luminosity Method)');
subplot(2, 2, 4);
imshow(gray_des);
title('Grayscale (Desaturation Method)');
waitforbuttonpress;
close(gcf);
end
function get_crop_image()
filename = './images/Tomato___Bacterial_spot.JPG';
img = imread(filename);
top_left = [50, 50];
bottom_right = [100, 100];
cropped_img = crop_image(img, top_left, bottom_right);
figure;
subplot(1, 2, 1);
imshow(img);
title('Original Image');
subplot(1, 2, 2);
imshow(cropped_img);
title('Cropped Image');
waitforbuttonpress;
close(gcf);
end
function compare_interpolation_techniques()
filename = './images/Tomato___Bacterial_spot.JPG';
scale_factor = 0.5;
% Read the image
img = imread(filename);
% Resize using different interpolation techniques
resized_nearest = resize_nearest_neighbor(img, scale_factor);
resized_bilinear = resize_bilinear(img, scale_factor);
resized_bicubic = resize_bicubic(img, scale_factor);
% Display original and resized images
figure;
subplot(2, 2, 1);
imshow(img);
title('Original Image');
subplot(2, 2, 2);
imshow(resized_nearest);
title('Nearest Neighbor');
subplot(2, 2, 3);
imshow(resized_bilinear);
title('Bilinear');
subplot(2, 2, 4);
imshow(resized_bicubic);
title('Bicubic');
waitforbuttonpress;
close(gcf);;
end
% gray_scale_test()
image_resize()
% get_crop_image()https://stockcake.com/i/underwater-deer-scene_1088628_999924
% compare_interpolation_techniques()
% download_images('https://stockcake.com/')
% capture_camera_image()
% compare_color_spaces('./images/Tomato___Bacterial_spot.JPG')
% extract_image_metadata('./images/Tomato___Bacterial_spot.JPG')
% Example usage
image_path ='./images/Tomato___Bacterial_spot.JPG'; % Replace with your image path
scale_factor = 1.5; % Example scale factor (adjust as needed)
translation = 50; % Example translation (adjust as needed)
% adjusted_image = scaling_translation(image_path, scale_factor, translation);