how can i control cluster

7 Ansichten (letzte 30 Tage)
Niaz Ahmad
Niaz Ahmad am 17 Feb. 2017
Kommentiert: Niaz Ahmad am 3 Mär. 2017
when i segment a color image its divided into three clusters i need one cluster of then which is of my interest, but every time the cluster changes i.e for each iteration and i get different cluster, simply i want to get fix cluster number not variable.
thanks in advance
  16 Kommentare
Niaz Ahmad
Niaz Ahmad am 2 Mär. 2017
[filename pathname]=uigetfile('*.jpg;*.png;*.jpeg;*.tif'); inputimage=imread([pathname filename]); outputimage=inputimage; [m,n,l]=size(outputimage); for i=1:m; for j=1:n; red = outputimage(i,j,1); green = outputimage(i,j,2); blue = outputimage(i,j,3); if (((red<green))||(red<blue)) outputimage(i,j,1)=0; outputimage(i,j,2)=0; outputimage(i,j,3)=0; end end end figure, subplot(2,1,1);imshow(inputimage);title ('Input Image'), subplot(2,1,2);imshow(outputimage);title ('Disease affected Area'), set(gcf, 'Position', get(0,'Screensize')); Please sir check this piece of code can we use it instead of clustering for achieving the above said result and if not so than any other alternate code?
Niaz Ahmad
Niaz Ahmad am 3 Mär. 2017
[filename pathname]=uigetfile('*.jpg;*.png;*.jpeg;*.tif'); inputimage=imread([pathname filename]); outputimage=inputimage; [m,n,l]=size(outputimage); for i=1:m; for j=1:n; red = outputimage(i,j,1); green = outputimage(i,j,2); blue = outputimage(i,j,3); if (((red<green))||(red<blue)) outputimage(i,j,1)=0; outputimage(i,j,2)=0; outputimage(i,j,3)=0; end end end figure, subplot(2,1,1);imshow(inputimage);title ('Input Image'), subplot(2,1,2);imshow(outputimage);title ('Disease affected Area'), set(gcf, 'Position', get(0,'Screensize')); Please sir check this piece of code can we use it instead of clustering for achieving the above said result and if not so than any other alternate code?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 17 Feb. 2017
You cannot control which cluster number a particular point is assigned to if you are using the kmeans algorithm.
kmeans uses random initialization of centroids, so any point could end up randomly near any centroid.
The Mathwork's kmeans does have a parameter to allow you to pass in initial centroids instead of using random centroids. However, the kmeans algorithm actively moves points between centroids, so the centroids "move around" and can effectively swap identities.
If you have prior knowledge of the "right" cluster number for points in two different centroids, then you can relabel the index numbers.
Always remember, though: kmeans does not have any idea what the data means, so there is no way it can be told that "cancer state III must be assigned cluster #2" for example.
  13 Kommentare
Image Analyst
Image Analyst am 28 Feb. 2017
I guess you didn't see my comment. How can you expect to get good answers on image processing without even providing an image? I'm surprised Walter even went this far with you.
Walter Roberson
Walter Roberson am 28 Feb. 2017
"which algorithm will be best for extracting more features"
Which-ever one works best for your data.
No-one knows what the best set of features or best algorithm is for your situation. There is no known useful mathematical model of what diseased leaves look like compared to healthy leaves for the diseases of interest to you for the types of plants of interest to you for the growing conditions of interest to you and photographed with the technologies and lighting conditions of interest to you -- but we would need such a mathematical model in order to predict what the best features and algorithm was.
The literature is full of papers along the lines of "We had a variety of plants and growing conditions and diseases of interest to us, and we experimented with a few different algorithms, and this is what happened; maybe this would work okay for you too." But none of those are your situation -- not unless you are copying their data and seeing what you can come up with.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Agriculture finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by