detect the blue color
Below is the code which i used there is no error in the code but not detecting the blue color
% Capture image from Kinect sensor
v = videoinput("kinect", 1, "RGB_640x480");
v.ReturnedColorspace = "rgb";
src = getselectedsource(v);
src.CameraElevationAngle = 15;
snapshot4 = getsnapshot(v);
delete(v);
clear src v;
% Convert RGB image to LAB color space
labImage = rgb2lab(snapshot4);
% Extract the L-channel (luminance)
LChannel = labImage(:,:,1);
% Define a threshold for blue color in the L-channel
blueThresholdLow = 0.85; % Adjust as needed
blueThresholdHigh = 0.10; % Adjust as needed
% Create binary mask for blue regions
blueMask = (LChannel >= blueThresholdLow) & (LChannel <= blueThresholdHigh);
% Apply the blue mask to the original RGB image to get the refined blue objects
refinedBlueObjects = bsxfun(@times, snapshot4, cast(blueMask, ‘like’, snapshot4));
% Display the original image and the refined blue objects
figure;
subplot(1, 2, 1), imshow(snapshot4), title(‘Original Image’);
subplot(1, 2, 2), imshow(refinedBlueObjects), title(‘Refined Blue Objects’);Below is the code which i used there is no error in the code but not detecting the blue color
% Capture image from Kinect sensor
v = videoinput("kinect", 1, "RGB_640x480");
v.ReturnedColorspace = "rgb";
src = getselectedsource(v);
src.CameraElevationAngle = 15;
snapshot4 = getsnapshot(v);
delete(v);
clear src v;
% Convert RGB image to LAB color space
labImage = rgb2lab(snapshot4);
% Extract the L-channel (luminance)
LChannel = labImage(:,:,1);
% Define a threshold for blue color in the L-channel
blueThresholdLow = 0.85; % Adjust as needed
blueThresholdHigh = 0.10; % Adjust as needed
% Create binary mask for blue regions
blueMask = (LChannel >= blueThresholdLow) & (LChannel <= blueThresholdHigh);
% Apply the blue mask to the original RGB image to get the refined blue objects
refinedBlueObjects = bsxfun(@times, snapshot4, cast(blueMask, ‘like’, snapshot4));
% Display the original image and the refined blue objects
figure;
subplot(1, 2, 1), imshow(snapshot4), title(‘Original Image’);
subplot(1, 2, 2), imshow(refinedBlueObjects), title(‘Refined Blue Objects’); Below is the code which i used there is no error in the code but not detecting the blue color
% Capture image from Kinect sensor
v = videoinput("kinect", 1, "RGB_640x480");
v.ReturnedColorspace = "rgb";
src = getselectedsource(v);
src.CameraElevationAngle = 15;
snapshot4 = getsnapshot(v);
delete(v);
clear src v;
% Convert RGB image to LAB color space
labImage = rgb2lab(snapshot4);
% Extract the L-channel (luminance)
LChannel = labImage(:,:,1);
% Define a threshold for blue color in the L-channel
blueThresholdLow = 0.85; % Adjust as needed
blueThresholdHigh = 0.10; % Adjust as needed
% Create binary mask for blue regions
blueMask = (LChannel >= blueThresholdLow) & (LChannel <= blueThresholdHigh);
% Apply the blue mask to the original RGB image to get the refined blue objects
refinedBlueObjects = bsxfun(@times, snapshot4, cast(blueMask, ‘like’, snapshot4));
% Display the original image and the refined blue objects
figure;
subplot(1, 2, 1), imshow(snapshot4), title(‘Original Image’);
subplot(1, 2, 2), imshow(refinedBlueObjects), title(‘Refined Blue Objects’); detect color, kinect MATLAB Answers — New Questions