How can I highlight a bounded region of an image when the user clicks inside that boundary?

1 次查看(过去 30 天)
Is there a method to return the image of just one cell and make rest of the image white? I need to highlight a cell using a mouse click and show just the cell, it is surrounded by a boundary. Should I use bwperim?
This is the cell. it is surrounded by white pixels. I need to click on a seed point and return the cell image within the white boundary and discard the rest of the image to white. I have used ginput for the mouse click.
  2 个评论
Randy Souza
Randy Souza 2013-5-16
I have restored the original text of this question.
@Ralph: this question has a clear subject and an accepted answer, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2013-4-26
There are lots of ways. Probably the easiest is to label your binary image (the one you used to create the perimeter from). Then from ginput(), get the label at that point and use ismember(labeledImage, labelNumber) to extract that particular blob from the binary image of all the blobs. Then you can do whatever you want to do, such as measure that blob only, or use that blob as a mask to blacken the original gray scale image outside the blob, or whatever else you want to do. Your request to "return the cell image within the white boundary" is not detailed enough to know what you mean - it's ambiguous, and there are several things that that could mean. See if you can do it yourself. Here are the steps for you do complete:
  1. call bwlabel on the binary image
  2. ginput on the labeled image
  3. turn x,y into row,column integers
  4. get value of the labeled image at that row, column.
  5. extract blob with that value from labeledImage using ismember
  6. binarize that and multiply it by the original image.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by