How to threshold images with objects that has lighter color than the background and vice versa?

11 visualizzazioni (ultimi 30 giorni)
Hi. I was doing a pest detection project. Some pests that I have identified have different colors: 1 is black and the other is white. When I try to use a code to threshold the images, the resulting threshold images for those pests with darker colors than the background is the object/pest is color white and the bg is black which is the proper result for thresholding. However, when I try the code to images with object/pests that has lighter background than the opposite, the result is inverted. What should I do? Please help me how to deal with it. I have problems when doing the segmentation part because of it.

Risposte (1)

Image Analyst
Image Analyst il 10 Mar 2018
In short,
binaryImage = grayImage >= someThresholdValue; % Find bright things.
binaryImage = grayImage <= someThresholdValue; % Find dark things.
  1 Commento
Manoj Prasad S.G
Manoj Prasad S.G il 29 Ott 2020
Sir now i want to threshold this image automatically without asking us to draw on the edges. i have already used the colour threshold in tool but isn't working. so can i get the code for this segmentation.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by