how to identify clear leaf in this image.

I am trying to identify greenness with the help of Tuned Tri-threshold Fuzzy Intensification Operators. I tried a lot to remove white pixels which around the edges of the final image.please help me to identify clear leaf of greenness.
Function
function out = TTFIO(image, tao, zeta)
[row col]=size(image);
%% Calculating the Membership Function
img = (image - min(image(:)))./(max(image(:)) - min(image(:)));
%% Applying Intensification Operators
for j = 1:row
for k = 1:col
if img(j,k) <= tao
enhanced(j,k) = 2*img(j,k)^2;
else
enhanced(j,k) = 1-2*(1-img(j,k))^2;
end
end
end
%% Tuning the Output
out=((enhanced).^(tao+zeta));
Read Image
zeta=.5;
x=im2double(imread('corn seedling wheat straw on sunny day.jpg'));
x=imresize(x,[256 256]);
figure; imshow(x);
img1=rgb2hsv(x);
H=img1(:,:,1).*255;
S=img1(:,:,2).*255;
V=img1(:,:,3).*255;
H( (H<5) | (H>150)) = 0;
H(H>65&H<80&S>2&10&V>150) = 0;
figure,imshow(uint8(S));
% x_R=x(:,:,1); x_G=x(:,:,2); x_B=x(:,:,3);
tao_R=.9; tao_G=.8; tao_B=.5;
R=(TTFIO(H,tao_R,zeta));
G=(TTFIO(S,tao_G,zeta));
B=(TTFIO(V,tao_B,zeta));
out=cat(3,R,G,B);
t=graythresh(out);
BW=im2bw(out,t);
figure,imshow(out)
BW=bwareaopen(BW,175);
BW = imclearborder(BW);
figure;
imshow(BW)
wheatstr.PNG
this is the original image
untitled.jpg
final result.

 Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 18 de Jul. de 2019
Editada: KALYAN ACHARJYA el 18 de Jul. de 2019

0 votos

You can look at color thresholding aproach like here, and for smothness of the edges use morphological operations. To get the best fit morpho operations in this case, may be it will take 15-30 min, but it can be done.

11 comentarios

tashu Dabariya
tashu Dabariya el 18 de Jul. de 2019
Editada: tashu Dabariya el 18 de Jul. de 2019
Sir, I tried this but it's not working pls help me.
a=0; b= 0; c=0; p=0; p1=0;
zeta=.5;
x=im2double(imread('corn seedling wheat straw on sunny day.jpg'));
x=imresize(x,[256 256]);
figure; imshow(x);
img1=rgb2hsv(x);
H=img1(:,:,1).*255;
S=img1(:,:,2).*255;
V=img1(:,:,3).*255;
H( (H<5) | (H>150)) = 0;
H(H>65&H<80&S>5&10&V>150) = 0;
figure,imshow(uint8(H));
% x_R=x(:,:,1); x_G=x(:,:,2); x_B=x(:,:,3);
tao_R=.9; tao_G=.8; tao_B=.5;
R=(TTFIO(H,tao_R,zeta));
G=(TTFIO(S,tao_G,zeta));
B=(TTFIO(V,tao_B,zeta));
out=cat(3,R,G,B);
for mm = 1:size(out,1)
for nn = 1:size(out,2)
if (out(mm,nn,2) -10) > out(mm,nn,1) & (out(mm,nn,2)-10) > out(mm,nn,3)
out(mm,nn,1) = out(mm,nn,1);
out(mm,nn,2) = out(mm,nn,2);
out(mm,nn,3) = out(mm,nn,3);
a=a+1;
else
out(mm,nn,1) = 250;
out(mm,nn,2) = 250;
out(mm,nn,3) = 250;
b=b+1;
end
end
end
p = a / (a + b);
p1 = p * 100;
imshow(out);
t=graythresh(out);
BW=im2bw(out,t);
figure,imshow(out)
BW=bwareaopen(BW,175);
BW = imclearborder(BW);
figure;
imshow(BW)
out(mm,nn,1) = 0;
out(mm,nn,2) = 0;
out(mm,nn,3) = 250;
imaageRGB=imread('leaf1.png');
for mm=1:size(imaageRGB,1)
for nn = 1:size(imaageRGB,2)
if (imaageRGB(mm,nn,2) - 5) > imaageRGB(mm,nn,1) && (imaageRGB(mm,nn,2) - 5) > imaageRGB(mm,nn,3)
imaageRGB(mm,nn,1) = imaageRGB(mm,nn,1);
imaageRGB(mm,nn,2) = imaageRGB(mm,nn,2);
imaageRGB(mm,nn,3) = imaageRGB(mm,nn,3);
else
imaageRGB(mm,nn,1) = 0;
imaageRGB(mm,nn,2) = 0;
imaageRGB(mm,nn,3) = 250;
end
end
end
imshow(imaageRGB);
KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Jul. de 2019
Editada: KALYAN ACHARJYA el 19 de Jul. de 2019
Is it helps?
tashu Dabariya
tashu Dabariya el 19 de Jul. de 2019
No Sir i tried alot but its not working..
zeta=.5;
x=im2double(imread('corn seedling wheat straw on sunny day.jpg'));
x=imresize(x,[256 256]);
figure; imshow(x);
img1=rgb2hsv(x);
H=img1(:,:,1).*255;
S=img1(:,:,2).*255;
V=img1(:,:,3).*255;
H( (H<5) | (H>150)) = 0;
H(H>65&H<80&S>5&10&V>150) = 0;
figure,imshow(uint8(H));
% x_R=x(:,:,1); x_G=x(:,:,2); x_B=x(:,:,3);
tao_R=.9; tao_G=.8; tao_B=.5;
R=(TTFIO(H,tao_R,zeta));
G=(TTFIO(S,tao_G,zeta));
B=(TTFIO(V,tao_B,zeta));
out=cat(3,R,G,B);
for mm=1:size(out,1)
for nn = 1:size(out,2)
if (out(mm,nn,2) - 5) > out(mm,nn,1) && (out(mm,nn,2) - 5) > out(mm,nn,3)
out(mm,nn,1) = out(mm,nn,1);
out(mm,nn,2) = out(mm,nn,2);
out(mm,nn,3) = out(mm,nn,3);
else
out(mm,nn,1) = 0;
out(mm,nn,2) = 0;
out(mm,nn,3) = 250;
end
end
end
imshow(out);
tashu Dabariya
tashu Dabariya el 19 de Jul. de 2019
Sir, this work but this is not working with the Tuned Tri-threshold Fuzzy Intensification Operators. I am trying to make a proposed method or is it any better option that greenness will be identified with other methods will you please provide the code?
my leaf images are in illumination conditions and the background of images are ash and wheat straw
imaageRGB=imread('corn seedling wheat straw on sunny day.jpg');
for mm=1:size(imaageRGB,1)
for nn = 1:size(imaageRGB,2)
if (imaageRGB(mm,nn,2) - 5) > imaageRGB(mm,nn,1) && (imaageRGB(mm,nn,2) - 5) > imaageRGB(mm,nn,3)
imaageRGB(mm,nn,1) = imaageRGB(mm,nn,1);
imaageRGB(mm,nn,2) = imaageRGB(mm,nn,2);
imaageRGB(mm,nn,3) = imaageRGB(mm,nn,3);
else
imaageRGB(mm,nn,1) = 0;
imaageRGB(mm,nn,2) = 0;
imaageRGB(mm,nn,3) = 250;
end
end
end
imshow(imaageRGB);
KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Jul. de 2019
I have tried with leaf single image only. For other images, I will have to check. Try to see color thresholding based on multiple sample images.
Good Wishes!
tashu Dabariya
tashu Dabariya el 19 de Jul. de 2019
ohkk thank you sir.
KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Jul. de 2019
Editada: KALYAN ACHARJYA el 19 de Jul. de 2019
Welcome @Tashu
gunturu gunturu
gunturu gunturu el 8 de Mzo. de 2021
what is enhanced(j,k) mean?
can you please clarify my dought
if posssble can you please give breaf explenation of TTFIO function
KALYAN ACHARJYA
KALYAN ACHARJYA el 8 de Mzo. de 2021
Editada: KALYAN ACHARJYA el 8 de Mzo. de 2021
where? @gunturu gunturu pls post the question as a new question (Open new thread)

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 18 de Jul. de 2019

Editada:

el 8 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by