現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
how can i control cluster
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Walter Roberson
2017 年 2 月 17 日
Please delete your code out of the tags and add it to your question.
Image Analyst
2017 年 2 月 18 日
Attach your image. It's hard to discuss image processing without an image, don't you agree? In many cases kmeans is not appropriate for doing color classification - you can probably easily think up such cases. I have a kmeans color classification routine/demo if you want proof.
Niaz Ahmad
2017 年 2 月 28 日
this is among one of the image here we want only the diseased portion to be extracted and to calculate its feature and then classify the disease in it????
Walter Roberson
2017 年 2 月 28 日
You see that yellowing? You also get that kind of yellowing when there is iron deficiency, which is not a disease. You also get leaf yellowing when the plant is being over-watered. You also get leaf yellowing when the plant is being under-watered.
You also get leaf yellowing when there is fungal rot of the roots; some definitions of "disease" exclude that.
You see that brown spot? You also get that brown spots not so different from that from some kinds of caterpillar or wasp damage, which is not a disease.
Now, it might be the case that those kinds of plants, in that area, are all watered properly, and do not get attacked by caterpillars or wasps. But that would be something contextual rather than absolute: in other cases, the yellowing or brown spot would have to be discounted as irrelevant.
Therefore there are no absolute features applicable to all leaf disease situations that can be applied. You need to come up with something relevant to your situation.
Image Analyst
2017 年 2 月 28 日
And what would k be for that image? 2? 4? More? What if the background were all "green" instead of dirt? Do you expect to have to determine k for each individual image?
Niaz Ahmad
2017 年 3 月 1 日
After segmentation i got this image, now to extract the background and shows only the affected area which forms circular ring, its actually early blight disease and i want to detect this disease in crop using image processing???
Image Analyst
2017 年 3 月 1 日
Just invert the mask that you used to blacken the image.
background = ~mask;
Niaz Ahmad
2017 年 3 月 1 日
how can we perform k-means clustering, where k=3 and for every image we should get only this form of cluster, means that the cluster should remain constant and does not change?

Walter Roberson
2017 年 3 月 1 日
We already talked about that below. You cannot control which cluster number will be assigned to which meaning. kmeans does not know anything about what the clusters mean.
Niaz Ahmad
2017 年 3 月 1 日
sir from the so discussion its clear that we cannot used k-mean clustering for the said work, so we have to use other methods for segmentation an order to obtain region of interest.
Walter Roberson
2017 年 3 月 1 日
No, the conclusion should be that you need to use techniques to match between cluster numbers and meaning. For example it might be the case that average rbg for the cluster allows you to determine which cluster you are dealing with.
Image Analyst
2017 年 3 月 1 日
編集済み: Image Analyst
2017 年 3 月 1 日
I agree with Niaz. As I've said before, kmeans is a crummy method to do clustering and classification on plant images in general (because you'll never know how many clusters there might be), though it might work fine on one particular image if you know certain things in advance (like number of clusters).
You might look into Microsoft's research on flower-finder: https://www.microsoft.com/en-us/research/blog/researchers-team-up-with-chinese-botanists-on-machine-learning-flower-recognition-project/
You could do a similar thing but with different leaf diseases.
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
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
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 件のコメント
Walter Roberson
2017 年 2 月 17 日
Suppose you cluster and you get back a variable named
clusteridx
Then start with
newidx = 0 * clusteridx;
Now if you have a point (r1, c1) that you know belongs to the cluster you want to be labeled as 1, and you have a point (r2, c2) that you know belongs to the cluster you want labeled as 2, then:
idx1 = clusteridx(r1, c1);
mask1 = clusteridx == idx1;
newidx( mask1 ) = 1;
idx2 = clusteridx(r2, c2);
mask2 = clusteridx == idx2;
newidx( mask2 ) = 2;
mask3 = clusteridx ~= 0 & ~mask1 & ~mask2;
newidx( mask3 ) = 3;
The problem is that in general you do not know ahead of time which point is going to belong to which cluster.
Do you know something ahead of time about the locations you want to label as 1? For example, do you know that it will be the brightest cluster, and that cluster 3 will be the darkest cluster? Or do you know that the cluster to be labeled as 1 is the red-est cluster?
With that kind of information known in advance, you could use regionprops() on the labeled image that is clusteridx and examine the properties to figure out which cluster index corresponds to which meaning, after which you can relabel.
Niaz Ahmad
2017 年 2 月 17 日
thank you sir for your valuable suggestions, sir can we do color segmentation for leaf related diseases without using clustering???
Walter Roberson
2017 年 2 月 17 日
"can we do color segmentation for leaf related diseases without using clustering???"
Yes. Use http://scholar.google.com to research color image segmentation methods; there are about 1 million articles to go through, so it is highly likely that somewhere in that haystack there is a method that does not use clustering.
Niaz Ahmad
2017 年 2 月 18 日
sir can we combine two cluster into one single cluster for example i have two cluster one is less affected with disease and the other one is more affected i want to combine them both and they should display to me as single disease cluster?
Niaz Ahmad
2017 年 2 月 19 日
Sir bundle of thanks for your kind guidance, sir which feature extraction and classification technique will be the best one for leaf related diseases?
Walter Roberson
2017 年 2 月 19 日
http://scholar.google.com shows at least 60 papers on that topic. I will leave it to you to read them and figure out which ones are best for you.
Niaz Ahmad
2017 年 2 月 27 日
sir can we used discrete wavelet transformation to extract features from RGB image, mean can we used for leaf diseases?
Niaz Ahmad
2017 年 2 月 28 日
Sir i am still confuse after studying so many papers that how to extract features from this attached image, means which algorithm will be best for extracting more features, please sir guide in this respect. thanks
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
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)


