Urgent help with connected component labeling
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello Experts,
I need some urgent help with matlab code, I have an exam in app. 2 hours and I need to write a function that gets a binary picture (matrix) and returns a matrix with the same size in which each connected componnent is tagged with a different label.
Please be so kind and provide me the code, it's very urgent.
2 comentarios
Geoff
el 21 de Mayo de 2012
You haven't been posting responses in your last question ever since you emailed me asking for private mentoring. If you have specific problems, whether they be syntactic, logical or conceptual, please describe them, and we may be able to help you. I do wonder how long you've known about this exam, and how much time you set aside to prepare, given that it appears you are having difficulty with this particular subject. Have you implemented a Union Find algorithm yet? Or did you have another method for relating the pixels?
Walter Roberson
el 21 de Mayo de 2012
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Respuestas (1)
Image Analyst
el 21 de Mayo de 2012
And what was wrong with the algorithm that kind Geoff described for you in your duplicate question? Did you want him to post his code so that you could turn his code in as your own for your test?
2 comentarios
Geoff
el 21 de Mayo de 2012
Hang on a minute.... An exam is designed to test YOUR ability, not ours!
I can point out a logic error right now though... "i" and j" will NEVER be greater than size(img,1) and size(img,2) respectively. You want to test if i > 1 or j > 1 here, but you need to read my answer to your other question again and/or think about exactly what that code does and when it does it.
But your concept is not going to work. All it does is individually labels all pixels that have a neighbour on the left or above. It doesn't actually connect the sets.
What you actually need to do here is implement Union Find and do this:
* if neighbour on left, union thispixel with leftpixel
* if neighbour above, union thispixel with abovepixel
It might be a little late to implement union find... But if you want to cheat, you can probably just google "union find code for matlab". In fact, Google solves about 90% of questions that are asked here.
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!