Removing labels in scikit-image


I have labeled an binary image <img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/3ILgh.png" data-original="https://i.stack.imgur.com/3ILgh.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

imageLabels = morphology.label(imageBinary, background=255)

However when I check the number of labels, I get 535 elements.


As a solution for this I thought about using measure.regionprops in order to remove the labels with a small pixel area. How would you guys approach this? I have tried the following, but for one reason or another the new array is no longer seen as a correct label element.

<pre class="lang-python prettyprint-override">i=0 for labelprop in measure.regionprops(imageLabels): if (labelprop.area > 100): imageLabels_keep.append(imageLabels[i]) i=i+1


I think morphology.remove_small_objects(image, min_px_size) does what you're looking for. Here's an example that uses that function:

<a href="http://scikit-image.org/docs/dev/auto_examples/applications/plot_coins_segmentation.html#edge-based-segmentation" rel="nofollow">http://scikit-image.org/docs/dev/auto_examples/applications/plot_coins_segmentation.html#edge-based-segmentation</a>


  • read coordinate text file for regionprop usage - Matlab
  • Returning specific regions [closed]
  • I have labeled regions, but, where are they on the image?
  • How to get the area of the bubble in the image using MATLAB?
  • Way to represent unknown file size in FTP LIST?
  • pthread_create memory leak
  • Overflow: hidden but i still want to have the empty scrollbar
  • Why are my web pages zoomed in when I open them in Opera Mobile?
  • How can I encode a filename according to RFC 2231?
  • Time taken for Hadoop job to execute
  • How do you remove the JComboBox 'click and see dropdown' functionality?
  • How to calculate networkdays minus holidays between 2 dates
  • Efficient algorithm to find additions and removals from 2 collections
  • XOR with Neural Networks (Matlab)
  • Detecting # in Scheme list
  • Correct implementation of List Iterator methods
  • Doctrine2 bulk import try to work with another entity
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • android google indoor map
  • Validate child input components on submit with Vee-Validate and vue js 2
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • AndEngine Applying Transparancy to AndEngine View
  • Read text file that is not in the main package in a runnable jar
  • std::remove_copy_if_ valgrind bytes in block are possibly lost in loss record
  • With Hadoop, can I create a tasktracker on a machine that isn't running a datanode?
  • Breeze - Deleted Items nav properties bug
  • How to do unit test for HttpContext.Current.Server.MapPath
  • Projection media query: browser support and workarounds?
  • Regex thinks I'm nesting, but I'm not
  • What is the “return” in scheme?
  • javaw.exe and eclipse startup problems
  • Check if a string to interpolate provides expected placeholders
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • RestKit - RKRequestDelegate does not exist
  • Traverse Array and Display in markup
  • How to disable jQuery.jplayer autoplay?
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • need help with bizarre java.net.HttpURLConnection behavior
  • How does Linux kernel interrupt the application?