Borrar filtros
Borrar filtros

Function and GUI error!!

2 visualizaciones (últimos 30 días)
Tinna Armasamy
Tinna Armasamy el 2 de Jun. de 2017
Comentada: Gopichandh Danala el 2 de Jun. de 2017
I am doing a GUI on soil image processing. Following are the task need to be performed by my GUI.
1)Upload image
[filename pathname]=uigetfile({'*.jpg';'*.tif'});
soil=strcat(pathname,filename);
axes(handles.axes1)
imshow(soil)
2)Image to be converted to binary image
soilgray=getimage(handles.axes1);
soilgray=rgb2gray(soilgray);
level=graythresh(soilgray);
im=im2bw(soilgray,level);
axes(handles.axes2);
imshow(im);
3)Find connected components of each particle in the soil
cc = bwconncomp(im,8);
n= cc.NumObjects;
set(handles.text11,'String',n);
4)Use region props to find the area,diameter and major axis length of each particle
Area = zeros(n,1);
Diameter = zeros(n,1);
MajorAxis = zeros(n,1);
Sand = zeros(n,1);
Silt = zeros(n,1);
Clay = zeros(n,1);
k = regionprops(cc,'Area','EquivDiameter','MajorAxisLength');
numClayParticles = 0;
numSiltParticles = 0;
numSandParticles = 0;
5)Do for loop to classify each particle size whether it is clay, sand or silt based on the size of the diameter
for m=1:n
Area(m) = k(m).Area;
Diameter(m) = k(m).EquivDiameter;
MajorAxis(m) = k(m).MajorAxisLength;
if Diameter(m) < 0.0236
Clay(m)=Diameter(m);
numClayParticles = numClayParticles + 1;
elseif Diameter(m) >=0.0236 && Diameter(m) < 0.5906
Silt(m)= Diameter(m);
numSiltParticles = numSiltParticles + 1;
elseif Diameter(m) >= 0.5906 && Diameter(m) < 23.6220
Sand(m) = Diameter(m);
numSandParticles = numSandParticles + 1;
end
end
6)From the number of type of particles from the for loop, calculate the percentage of clay,silt and sand
ClayPercentage = (numClayParticles/n)*100;
set(handles.text15,'String',ClayPercentage);
SiltPercentage = (numSiltParticles/n)*100;
set(handles.text16,'String',SiltPercentage);
SandPercentage = (numSandParticles/n)*100;
set(handles.text17,'String',SandPercentage);
7)This is done to determine the type of soil based on the USDA Soil classification triangle based on particle size of soil image
I have done the coding but I am unable to perform the for loop accurately and not getting accurate result.I have problem from step 5 onward.Please help with the coding above! Thank you!
  3 comentarios
Tinna Armasamy
Tinna Armasamy el 2 de Jun. de 2017
I will correct the error. Meanwhile, attached is the sample image. Thank you for the assistance.
Gopichandh Danala
Gopichandh Danala el 2 de Jun. de 2017
I ran through your code on my system for the above image and I got
numClayParticles = 0;
numSiltParticles = 0;
numSandParticles = 85;
whereas n = 86..
I think your problem is with the segmentation itself, I don't think you are able to get proper segmented results, check segmentation

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Agriculture en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by