Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Matlab中使用颜色阈值应用程序屏蔽绿色像素?_Matlab_Image Processing_Matlab Figure_Image Segmentation_Feature Extraction - Fatal编程技术网

如何在Matlab中使用颜色阈值应用程序屏蔽绿色像素?

如何在Matlab中使用颜色阈值应用程序屏蔽绿色像素?,matlab,image-processing,matlab-figure,image-segmentation,feature-extraction,Matlab,Image Processing,Matlab Figure,Image Segmentation,Feature Extraction,我在做植物病害检测和分类。首先进行预处理,然后进行图像分割。在分割中,我使用matlab中的颜色阈值应用程序对RGB图像进行背景去除。然后,我将对绿色像素进行掩蔽,绿色级别高于红色和蓝色的像素通过应用掩蔽进行识别和移除。这是基于这样一个事实,即这些绿色像素最有可能代表叶子中的健康区域。因此,在去除背景和绿色像素后,图像中留下的区域就是我们感兴趣的区域。** 如何屏蔽绿色像素以及如何使用从中获取的阈值 在matlab中使用颜色阈值应用程序去除背景 请回答我!这是我的主要代码: a = imread

我在做植物病害检测和分类。首先进行预处理,然后进行图像分割。在分割中,我使用matlab中的颜色阈值应用程序对RGB图像进行背景去除。然后,我将对绿色像素进行掩蔽,绿色级别高于红色和蓝色的像素通过应用掩蔽进行识别和移除。这是基于这样一个事实,即这些绿色像素最有可能代表叶子中的健康区域。因此,在去除背景和绿色像素后,图像中留下的区域就是我们感兴趣的区域。**

如何屏蔽绿色像素以及如何使用从中获取的阈值 在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应用程序于2018年3月26日自动生成 %-------------------------------------------------------

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;
函数[BW,maskedRGBImage]=createMask(RGB)
%将RGB图像转换为所选颜色空间
RGB=im2double(RGB);
cform=makecform('srgb2lab','AdaptedWhitePoint',whitepoint('D65'));
I=ApplyForm(RGB,cform);
%根据直方图设置定义通道1的阈值
通道1min=0.408;
channel1Max=99.533;
%根据直方图设置定义通道2的阈值
通道2min=-27.701;
信道2max=14.325;
%根据直方图设置定义通道3的阈值
通道3min=5.282;
信道3max=50.539;
%基于选定的直方图阈值创建遮罩
BW=(I(:,:,1)>=channel1Min)和(I(:,:,1)=channel2Min)和(I(:,:,2)=channel3Min)和(I(:,:,3)