i do plant disease detection and classification.i need a code to remove green pixels in matlab.i have done background removal using color thresholder app in matlab. I mean green pixels remove- " the pixels where the level of green is higher than red and blue are identified and remove by application of the mask.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" said in my thesis reference paper. If i get this green pixels remove, then i will do feature extraction using GLCM. So, how do i continue to remove green pixels? My code is given in the following:
% Title : Potato Leaf Diseases Detection based on Multiclass SVM
clc
close all
clear all
[filename, pathname] = uigetfile({'*.*';'*.bmp';'*.jpg';'*.gif'}, 'Pick a Leaf Image File');
I = imread([pathname,filename]);
I = imresize(I,[256,256]);
figure, imshow(I); title('Input Leaf Image');
%Preprocessing using median filtering
I1 = rgb2gray(I);
I2 = medfilt2(I1,[3 3]);
%imshow(I2);title('Filtered Image');
%%Image Segmentation
%Background Removing using Color Thresholder app
[bw,rgb] = background_removal(I);
This is my image after background masking using color thresholder app in matlab; then, how to remove green pixels ? I want to get only disease leaf area.

 採用された回答

Matt J
Matt J 2018 年 7 月 20 日

0 投票

val= max(rgb,[],3);
mask=uint8(rgb(:,:,2)~=val);
imshow(rgb.*mask);

11 件のコメント

Yoon ThiriZaw
Yoon ThiriZaw 2018 年 7 月 20 日
Thanks, Matt! Can u explain me theory concept of this code? Please!
Matt J
Matt J 2018 年 7 月 20 日
Wasn't that explained to you in your previous and very similar thread?
Yoon ThiriZaw
Yoon ThiriZaw 2018 年 7 月 20 日
it tells me error when i run this. "Error using .* Integers can only be combined with integers of the same class, or scalar doubles." How do i solve?
Matt J
Matt J 2018 年 7 月 20 日
Convert mask to the same integer type as rgb, or vice versa, e.g.,
imshow(uint8(rgb).*mask);
Yoon ThiriZaw
Yoon ThiriZaw 2018 年 7 月 22 日
It until false. Undefined function unit8 for input arguments of logical said me.
Matt J
Matt J 2018 年 7 月 22 日
You typed "uint8" incorrectly.
Yoon ThiriZaw
Yoon ThiriZaw 2018 年 7 月 22 日
編集済み: Yoon ThiriZaw 2018 年 7 月 22 日
It until false,Matt in (.*) matrix dimensions must agree. Problem is .* in this.
Image Analyst
Image Analyst 2018 年 7 月 22 日
Yoon, it looks like you're using my code for finding the leaf, and I usually mask RGB images with a mask using this code:
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
Perhaps you deleted that when you were adapting it.
Yoon ThiriZaw
Yoon ThiriZaw 2018 年 7 月 23 日
Yes! Image Analyst, thanks! I get this code but when i do feature extraction using GLCM(Gray Level Cooccurrence Matrix) as the next step, i think it is false. How do i continue?
Image Analyst
Image Analyst 2018 年 7 月 23 日
You fix the bug that is giving you false. graycomatrix() and graycoprops() do not return false.
Yoon ThiriZaw
Yoon ThiriZaw 2018 年 7 月 23 日
編集済み: Yoon ThiriZaw 2018 年 7 月 23 日
Can you give me code as an feature extraction example? I don't know how to explain when my presentation this segmentatin step bsxfun.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAgriculture についてさらに検索

製品

リリース

R2014a

質問済み:

2018 年 7 月 20 日

編集済み:

2018 年 7 月 23 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by