我正在做植物病害检测和分类 . 首先,我做预处理步骤,然后进行图像分割 . 在分割中,我使用matlab中的颜色阈值应用程序在RGB图像中进行背景去除 . 然后,我将掩盖绿色像素, the pixels where the level of green is higher than red and blue are identified and removed by application of the mask. This is based on the fact that these green pixels most probably represent healthy areas in the leaves. Thus, after removing the background and green pixels, the region left in an image is the region of our interest. **

我如何屏蔽绿色像素以及如何使用matlab中使用颜色阈值应用程序从背景移除中获取阈值?

请回答我!这是我的主要代码:

a = imread('LB.jpg');
subplot(2,3,1);
imshow(a);title('Input Image');

b = rgb2gray(a);
subplot(2,3,2);
imshow(b);title('Grey Image');

c = medfilt2(b,[3 3]);
subplot(2,3,3);
imshow(c);title('Filtered Image using 3*3 window');

[bw,rgb] = background_removal(a);
subplot(2,3,4);
imshow(bw);title('Binary Image');
subplot(2,3,5);
imshow(rgb);title('Background Removed');

并且,此代码是在matlab中使用颜色阈值器去除背景:%由colorThresholder应用程序自动生成于201-Mar-2018%----------------------- --------------------------------

function [BW,maskedRGBImage] = createMask(RGB)

% Convert RGB image to chosen color space
RGB = im2double(RGB);
cform = makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('D65'));
I = applycform(RGB,cform);

% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.408;
channel1Max = 99.533;

% Define thresholds for channel 2 based on histogram settings
channel2Min = -27.701;
channel2Max = 14.325;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 5.282;
channel3Max = 50.539;

% Create mask based on chosen histogram thresholds
BW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
    (I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
    (I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);

% 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;