albusdemens
albusdemens

Reputation: 6624

Python - detect elements of a region

I have an array made of 1 and 0 (image below), and I am working on a Python script that detects the borders of the central region (the big white blob) and marks all the internal points as 1. How would you do it?

I wrote a piece of code that does repeated connectivity search, but this doesn't seem the way to go - the region changes shape and new areas are added.

enter image description here

Upvotes: 4

Views: 1061

Answers (1)

user2841651
user2841651

Reputation:

as I can't put a comment i put it here.

I had a problem close to yours: I wanted to select several holes and then calculate the area, the roundness...

What I did was to use the java implementation of python (jython) by which I could use a library called imageJ which is dedicated to image processing (all is include in Fiji). Navigating in the library is a bit fastidiuous but it is powerfull one

Here is the wand tool: http://rsbweb.nih.gov/ij/developer/api/ij/gui/Wand.html Have a look here for "How getting pixels of a ROi" : http://fiji.sc/Introduction_into_Developing_Plugins#ImageJ.27s_API

Upvotes: 1

Related Questions