이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
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
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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)


