Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a function to extract regions from a 2D image #1

Closed
wants to merge 4 commits into from
Closed

add a function to extract regions from a 2D image #1

wants to merge 4 commits into from

Conversation

awalter-bnl
Copy link
Contributor

This commit adds a function <extract_regions> which extracts regions from a 2D array and returns a dictionary containing the regions as well as the arrays related to those regions.

@awalter-bnl awalter-bnl added the Do not merge Do not yet merge label Jul 6, 2018
@awalter-bnl awalter-bnl closed this Jul 9, 2018
@awalter-bnl awalter-bnl reopened this Jul 9, 2018
@awalter-bnl awalter-bnl closed this Jul 9, 2018
@awalter-bnl awalter-bnl reopened this Jul 9, 2018
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@bd0b95f). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #1   +/-   ##
=========================================
  Coverage          ?   49.04%           
=========================================
  Files             ?        5           
  Lines             ?      314           
  Branches          ?        0           
=========================================
  Hits              ?      154           
  Misses            ?      160           
  Partials          ?        0
Impacted Files Coverage Δ
rixs/tests/test_preliminary_processing.py 100% <100%> (ø)
rixs/preliminary_processing.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd0b95f...2d86efe. Read the comment docs.

@awalter-bnl
Copy link
Contributor Author

FYI, I am waiting on the feedback, via basecamp, on weather this should be here or in NSLS-II-SIX/sixtools before removing the "Do not merge" tag.

@danielballan
Copy link
Member

The return value of this function -- a dictionary with labels mapped to subarrays -- is not the most useful representation. It is more useful to pass around slices:

regions = {1: [slice(1, 2), slice(3, 4)], 2: [slice(3, 6), slice(2, 4)]}

or so-called label arrays, which are a "paint by number" representation of this array:

labels = np.zeros_like(arr)  # an array of zeros with the same dimensions as arr
for i, region.items()
    # Paint the subarray region with the number i.
    labels[region] = i

Then our label array labels looks like:

array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 1., 0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
       [0., 0., 2., 2., 0., 0., 0., 0., 0., 0.],
       [0., 0., 2., 2., 0., 0., 0., 0., 0., 0.],
       [0., 0., 2., 2., 0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])

Which of these is better depends on that context. Scikit-image provides tools for switching between them.

@danielballan
Copy link
Member

@awalter-bnl
Copy link
Contributor Author

This is a good point, and much better form a memory usage point of view. I am about to move this stuff to NSLS-II-SIX/sixtools but will make this change at the same time.

@awalter-bnl
Copy link
Contributor Author

closing this as it is being moved to NSLS-II-SIX/sixtools

@awalter-bnl awalter-bnl deleted the raw_image_slicing branch July 16, 2018 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Do not merge Do not yet merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants