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

12 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Image Analyst
Image Analyst el 10 de Mzo. de 2018
In short,
binaryImage = grayImage >= someThresholdValue; % Find bright things.
binaryImage = grayImage <= someThresholdValue; % Find dark things.
  1 comentario
Manoj Prasad S.G
Manoj Prasad S.G el 29 de Oct. de 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.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by