-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitColorChannels.m
More file actions
33 lines (27 loc) · 1.14 KB
/
splitColorChannels.m
File metadata and controls
33 lines (27 loc) · 1.14 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
function [croppedImage_red, croppedImage_green, croppedImage_blue] = splitColorChannels(croppedImage, crop, plotData)
%Isolating channels - RED
croppedImage_red = croppedImage; %initializing
croppedImage_red(:, :, 2:3) = 0; %removing green and blue channels
%Isolating channels - GREEN
croppedImage_green = croppedImage; %initializing
%croppedImage_green(:, :, 1:2:3) = 0; %removing red and blue channels
croppedImage_green(:, :, 1) = 0; %removing red channel
croppedImage_green(:, :, 3) = 0; %removing blue channel
%Isolating channels - BLUE
croppedImage_blue = croppedImage; %initializing
croppedImage_blue(:, :, 1:2) = 0; %removing red and green channels
if plotData
fig4 = figure(4);
set(fig4,'Position', [1500, 1000, 1200, 800]);
clf
subplot(1, 3, 1)
imshow(croppedImage_red)
title(sprintf('RED - Cropped with xmin = %d and ymin = %d', crop(1), crop(2)))
subplot(1, 3, 2)
imshow(croppedImage_green)
title(sprintf('GREEN - Cropped with xmin = %d and ymin = %d', crop(1), crop(2)))
subplot(1, 3, 3)
imshow(croppedImage_blue)
title(sprintf('BLUE - Cropped with xmin = %d and ymin = %d', crop(1), crop(2)))
end
end