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

2to3 #9

Merged
merged 5 commits into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions example/example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import (
division,
print_function,
)

import skimage.data
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
Expand Down
10 changes: 6 additions & 4 deletions selectivesearch/selectivesearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import division

import skimage.io
import skimage.feature
import skimage.color
Expand Down Expand Up @@ -176,7 +178,7 @@ def _extract_regions(img):
tex_grad = _calc_texture_gradient(img)

# pass 3: calculate colour histogram of each region
for k, v in R.items():
for k, v in list(R.items()):

# colour histogram
masked_pixels = hsv[:, :, :][img[:, :, 3] == k]
Expand Down Expand Up @@ -291,7 +293,7 @@ def selective_search(

# mark similarities for regions to be removed
key_to_delete = []
for k, v in S.items():
for k, v in list(S.items()):
if (i in k) or (j in k):
key_to_delete.append(k)

Expand All @@ -300,12 +302,12 @@ def selective_search(
del S[k]

# calculate similarity set with the new region
for k in filter(lambda a: a != (i, j), key_to_delete):
for k in [a for a in key_to_delete if a != (i, j)]:
n = k[1] if k[0] in (i, j) else k[0]
S[(t, n)] = _calc_sim(R[t], R[n], imsize)

regions = []
for k, r in R.items():
for k, r in list(R.items()):
regions.append({
'rect': (
r['min_x'], r['min_y'],
Expand Down