Threshold value question using otsu method

26 ビュー (過去 30 日間)
Packiya
Packiya 2014 年 12 月 24 日
I am doing Plant leaf disease detection & classification project. In that i am using otsu method to calculate threshold value for all leaves. But thershold value for some type of leaves could not detect the diseased part correctly..so i am using some constant threshold value(0.17,0.6). Can anyone please give some other method to find threshold value other than otsu method that is suitable for all type of leaves..

採用された回答

Image Analyst
Image Analyst 2014 年 12 月 30 日
See my attached code. I use an image with black background and even black spots inside it. I correctly identify the diseased areas and give the area fraction of them relative to the entire leaf area (diseased + healthy areas).
If this solves your question, please mark as Accepted.
  27 件のコメント
Asmalina Mohamed Saat
Asmalina Mohamed Saat 2020 年 10 月 20 日

サインインしてコメントする。

その他の回答 (6 件)

Sean de Wolski
Sean de Wolski 2014 年 12 月 24 日
Show us an image! Without an image, it's very difficult if not impossible to guess at what you need.
Have you tried the multilevel otsu threshold? I.e. the Image Processing function imquantize?
  7 件のコメント
Spandan Tiwari
Spandan Tiwari 2015 年 1 月 15 日
A clarification - the function to use for multilevel Otsu is multithresh . It outputs the threshold level(s). If required, the image can then be quantized using those thresholds using imquantize.

サインインしてコメントする。


Image Analyst
Image Analyst 2014 年 12 月 24 日
I almost never use Otsu. It's usually no good. It's good mostly in cases with high contrast images with widely separated bimodal histograms, like where there is a uniform object on a uniform background and they have very different intensities. In real world situations, Otsu is often/usually not the best choice.
Actually using a fixed threshold like you're doing is a very good but under-used and under-appreciated method. People always want to use automatic thresholding but simple-minded autothresholding methods like Otsu have the drawback in that they always have to find a threshold somewhere in the histogram. Let's say you're looking at some image and the disease or stuff you want to find can be anywhere from 0% area fraction all the way up to 100% area fraction. Let's say you have a hump centered at 100 for good/normal/non-diseased pixels, and as the pixel goes "bad" the pixels get darker, which means their histogram shifts darker. Let's say one that was 100% bad would give you a hump at 50 gray levels. But what if you had a 100% bad image and Otsu would try to split that histogram and might give you something around 48 or 55 or whatever. It would give you the wrong area fraction because it was forced to find a threshold in a histogram hump that was essentially all the same - all bad. It would be much better to just say that anything below, say, 75 is bad and above 75 is good. That way you can get accurate area fractions all the way from 0% to 100%. If you have good control over your lighting and exposure so that similar images produce similar gray levels, then using a fixed threshold is a fine idea.
But in general, you need to decide upon a thresholding scheme based on the complete range of images that you expect to encounter. You haven't shown us even a single image, much less the entire span of images you expect the algorithm to be able to handle. Usually people asking for image processing advice attach an image to we don't have to work "blind."
  1 件のコメント
Sean de Wolski
Sean de Wolski 2014 年 12 月 24 日
I agree that fixed thresholds are useful, especially for x-rays where the pixel values are a direct measure of energy passing through.
However, Otsu is appealing too for images where there is an object in the foreground and a background. It can do a good job dealing with changes in lighting etc.

サインインしてコメントする。


Anand
Anand 2015 年 1 月 15 日
I haven't read the entire thread above. I'm sure there's a lot of good information there. I take it you are trying to threshold the 'diseased' portion of the leaf. So, essentially you want an image with disease pixels vs non-disease pixels.
I tried using the colorThresholder App with a couple of the images you've attached.
Here's how it looks:
im = imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/23137/Bacterial1.jpg');
% Open the colorThresholder
colorThresholder(im)
The hue channel in the HSV color space seems to separate the disease pretty well, so select HSV. Once the image opens in the HSV color space, move the hue slider appropriately to threshold the image.
Now export the code and use this on the other images.
Hope this helps!
  1 件のコメント
Packiya
Packiya 2015 年 1 月 23 日
Thank u so much for your effort.

サインインしてコメントする。


gururaj moger
gururaj moger 2016 年 4 月 8 日
how to check or detect the things instead of leaf and it must show it is not leaf
  1 件のコメント
Image Analyst
Image Analyst 2016 年 4 月 8 日
Find the leaf and then invert the mask
nonGreenMask = ~greenMask;

サインインしてコメントする。


Raheel Rehman
Raheel Rehman 2017 年 1 月 7 日
Can you please share the code?
  1 件のコメント
Image Analyst
Image Analyst 2017 年 1 月 7 日
What code are you talking about? In my answer, I did post my code.

サインインしてコメントする。


tan aik hong
tan aik hong 2018 年 10 月 5 日
thanks and it is very helpful for my project, but I had some problem, which is if the image of the leaf is healthy, through the code above, I had got the healthy region and diseases region. may I know is there any code that able to choose the image of leaf whether it is healthy or not. thanks
  1 件のコメント
Image Analyst
Image Analyst 2018 年 10 月 5 日
No, that is the part that you need to do yourself, or hire someone to do. But once they've all been analyzed, and you have a boolean variable "isDiseased", then you can find the index of diseased ones, something like this
for k = 1 : length(isDiseased)
if ~isDiseased
continue; % Skip healthy ones.
end
thisFileName = allFileNames{k};
imshow(thisFileName);
drawnow;
end

サインインしてコメントする。

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by