what are the preprocessing steps to get a binary Image using OTSU?

Hi All
I am able to get a binary image for the attached example by defining threshold manually (trial and error). However, When I use Otsu thresholding, the result is not satisfactory. What pre-prosessing would be useful before I apply OTSU for the attached Image? I also present the result when I use OTSU AS below.
Any other methods to get a binary Image are welcome.
Thanks
binary_image.JPG

 Respuesta aceptada

Image Analyst
Image Analyst el 25 de Nov. de 2018
Try a top hat filter. See attached.
0000 Screenshot.png

11 comentarios

Thank you very much for your help. It is highly appreciated. The binary image is seperated in the end. Can we connect them together as well?
The last portion of the binary image is important to me, as I am reporting the postion of the tip point of the shape. When I get a vertical alignment, I see that around tip of the object is not visible in binary image.
The two blobs do not need to be connected. To find the tip, project vertically then use find().
horizontalProfile = sum(mask, 1);
lastColumn = find(horizontalProfile, 1, 'last');
I have already reported the tip position in x an y direction. My point is the position is not very accurate when I compare with the original image's tip position. Because binary image is perfectly obtained at the tip. I hope I am clearer.
Is the tip always inserted at the same line/row/y level? Do you have good control over the light level? Like is the background intensity always exactly the same in every image?
No, the tip can be anywhere in the image plane, the light level is set to maximum in microscope. So light level will be the same in every image taken at different position. In this case, I assume the background intensity will be always EXACTYLY the same.
How accurate do you need it to be? With all that refraction I don't think you're going to get reliable subpixel accuracy. Isn't it good enough to be within a pixel or two or three? Why does it need to be any more accurate?
How is the thing being inserted? If it's by hand, then being accurate to within less than a pixel is, I think, just going to give you an arbitrary location that it you wanted a tenth of a second later to snap the picture, the tip would be several pixels away, so why is the location at that exact time so important.
Let's say you had the tip location accurate to within a millionth of a pixel. What are you going to do with that information?
Hi Image analyst
The accuracy is good enough to be within two or three pixels or even more abit. The object will not be located by hand. I will have a positional control over it with less than a micron resolution. I just need to compare the positions based on changing different parameters at the same lighting conditions The important thing for me to have more or less same binary image ( that is I am trying to have a robust way to get a binary image of the object).
Please let me know if you have any more questions. I would like to thank your help and interest.
I gave you an objective way of getting the binary image. I don't understand why it's not good enough yet. You say "I have already reported the tip position in x an y direction. My point is the position is not very accurate when I compare with the original image's tip position. Because binary image is perfectly obtained at the tip. I hope I am clearer." Well, it's not clearer. What are the two positions and why is one not very accurate? How do you know it's not accurate?
Because I have checked the tip location manually by using imtool and compared result I have got from binary image. There are differences around 20 pixels. Even when I align them, I can see that at the end of objec is not binarized well. It is shorter than the original one.
For example, the original tip position is (373,515). The position obtained from the binary image is (355,513).
My aim is just to be as close as posible to the original location.
It looks like you're trying to find the black stuff whereas I was trying to find the bright stuff inside the black stuff, so I got rid of the last part of the loop and looped over structuring element radii to see which one give the best values. Did you try that? I did and am attaching the code and the image it makes. Pick whatever radius looks best to you. Or you could try to change the shape of the structuring element from a disk to a cross or something to see if that does better.
0001 Screenshot.png

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 23 de Nov. de 2018
Editada: Image Analyst el 23 de Nov. de 2018
Try this:
binaryImage = imbinarize(grayScaleImage);
You can also try my interactive method in my File Exchange.
Or you can try my triangle thresholding method, attached.
You should also do a background correction on the image before using a global threshold. See attached demo.

1 comentario

Hi Image Analyst
Thanks for your help. I could not implement triangle threshold algorithm unfortunately. Matlab gets busy and give an error in the end... I have tried background correction. Unfortunately, results are not satisfactory. It is so confusing for me to get a binary image from my attached image. On the other hand not having the same or even similar results ( as in manual thresholding) from another algorithms, such as OTSU...
I would appreciate if you look into my image and tell me what could be the problem.
Kind regards,

Iniciar sesión para comentar.

Categorías

Preguntada:

el 22 de Nov. de 2018

Comentada:

el 27 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by