How to separate the foreground from the background in an image?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Warisa Theerathamtada
el 26 de Dic. de 2022
Respondida: Image Analyst
el 26 de Dic. de 2022
I need to seperate foreground(medicine and coin) from background I tried to crop image(medicine and coin) and use threshold , imclose,imopen
This is my result 

but it dose not perfect.
In my intention I need use same code with all pictures (I drag picture for information)
Do you have any ideal ? Thank you.
0 comentarios
Respuesta aceptada
Image Analyst
el 26 de Dic. de 2022
Then you can interactively adjust the threshold. If it's still not perfect, and you need perfect, you will have to fix your image capture situation. For one thing you could use a different background color. Not white but some contrasting color like green. Then you can do color segmentation with the Color Threshold App on the Apps tab of the took ribbon.
Secondly, you need to have better lighting. Either light coming from all around the sides to eliminate shadows, or a very broad overhead illumination (like large LED panel or an umbrella type of light.
Third, if you want accurate diameters you must reduce the cone angle from your lens to the subject. This means using a longer focal length lens and backing your camera away so the light rays are more parallel. Of course the best way is to use a concentric lens, rather than a regular lens. This has parallel rays entering the camera so you will never see the edges of the objects, only the tops. The downside is they're very expensive, and you'd need a lens diameter that is at least as large as your field of view.
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!