-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
102 lines (64 loc) · 2.94 KB
/
main.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
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
%% Selección de la imagen para procesar
image1 = imread('imgs/diomedes.jpg');
imageGpuR = gpuArray(image1(:,:,1));
imageGpuG = gpuArray(image1(:,:,2));
imageGpuB = gpuArray(image1(:,:,3));
imshow(image1)
%% Transformación 1
timer2 = tic;
imageTransform2 = image1;
[newImageR, newImageG] = arrayfun(@transformation1, imageGpuB);
newImageR = gather( newImageR ); % Fetch the data back from the GPU
newImageG = gather( newImageG ); % Fetch the data back from the GPU
imageTransform2(:,:,1) = uint8(newImageR);
imageTransform2(:,:,2) = uint8(newImageG);
figure, imshow(imageTransform2)
endTime2 = toc(timer2);
%% Transformación 2
timer1 = tic;
imageTransform1 = image1;
newImage = arrayfun(@transformation2, imageGpuR, imageGpuG);
newImage = gather( newImage ); % Fetch the data back from the GPU
imageTransform1(:,:,3) = uint8(newImage);
figure, imshow(imageTransform1)
endTime1 = toc(timer1);
figure, plot3(imageTransform1(:,:,1), imageTransform1(:,:,2), imageTransform1(:,:,3), 'x')
figure, plot3(image1(:,:,1), image1(:,:,2), image1(:,:,3), 'x')
%% Transformación 3
timer1 = tic;
imageTransform1 = image1;
[NegativeRedChannel, NegativeGreenChannel, NegativeBlueChannel] = arrayfun(@transformation3, imageGpuR, imageGpuG, imageGpuB);
newImageR = gather( NegativeRedChannel); % Fetch the data back from the GPU
newImageG = gather( NegativeGreenChannel); % Fetch the data back from the GPU
newImageB = gather( NegativeBlueChannel); % Fetch the data back from the GPU
imageTransform1(:,:,1) = uint8(newImageR);
imageTransform1(:,:,2) = uint8(newImageG);
imageTransform1(:,:,3) = uint8(newImageB);
figure, imshow(imageTransform1)
endTime1 = toc(timer1);
figure, plot3(imageTransform1(:,:,1), imageTransform1(:,:,2), imageTransform1(:,:,3), 'x')
figure, plot3(image1(:,:,1), image1(:,:,2), image1(:,:,3), 'x')
%% Transformación 4
timer1 = tic;
imageTransform1 = image1;
[NegativeRedChannel, NegativeGreenChannel, NegativeBlueChannel] = arrayfun(@transformation4, imageGpuR, imageGpuG, imageGpuB);
newImageR = gather( NegativeRedChannel); % Fetch the data back from the GPU
newImageG = gather( NegativeGreenChannel); % Fetch the data back from the GPU
newImageB = gather( NegativeBlueChannel); % Fetch the data back from the GPU
imageTransform1(:,:,1) = uint8(newImageR);
imageTransform1(:,:,2) = uint8(newImageG);
imageTransform1(:,:,3) = uint8(newImageB);
figure, imshow(imageTransform1)
endTime1 = toc(timer1);
figure, plot3(imageTransform1(:,:,1), imageTransform1(:,:,2), imageTransform1(:,:,3), 'x')
figure, plot3(image1(:,:,1), image1(:,:,2), image1(:,:,3), 'x')
%% Transformacion 5
timer2 = tic;
imageTransform2 = image1;
[newImageR, newImageG] = arrayfun(@transformation5, imageGpuB);
newImageR = gather( newImageR ); % Fetch the data back from the GPU
newImageG = gather( newImageG ); % Fetch the data back from the GPU
imageTransform2(:,:,1) = uint8(newImageR);
imageTransform2(:,:,2) = uint8(newImageG);
figure, imshow(imageTransform2)
endTime2 = toc(timer2);