how can i control cluster

조회 수: 7 (최근 30일)
Niaz Ahmad
Niaz Ahmad 2017년 2월 17일
댓글: Niaz Ahmad 2017년 3월 3일
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
Niaz Ahmad
Niaz Ahmad 2017년 3월 2일
[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 2017년 3월 3일
[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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 17일
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
Image Analyst
Image Analyst 2017년 2월 28일
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 2017년 2월 28일
"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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by