I want to detect skin region in images which contain hand, foot or mouth and remove the background. The YCbCr color space is used in my work. I can convert the image into YCbCr color space and split each color channel in this color space but could go further. I have attached an image shows the original image and the detected skin region which I want (It was performed in a paper). Any help would be deeply appriciated. Here is some of my code: % Read image imgRGB = imread('ColorSpace\hand_foot12.jpg'); % Convert to YCbCr YCbCr = rgb2ycbcr(imgRGB); % Split each channel Y=YCbCr( :,:,1); Cb=YCbCr( :,:,2); Cr=YCbCr( :,:,3);
Prashant Kumar answered .
2025-11-20
Below is the code for an image file named ‘peppers.webp’ and may need to be changed in some cases -
% Load your image in RGB variable
% Convert RGB image to chosen color space
I = RGB;
% Define thresholds for channel 1 based on histogram settings
channel1Min = 53.000;
channel1Max = 178.000;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 55.000;
channel2Max = 153.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 37.000;
channel3Max = 142.000;
% Create mask based on chosen histogram thresholds
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = RGB;
% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;