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

Bug fix: Ignore rays ending at image boundary #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elcombato
Copy link

Indexing the ndarray edges with a negative index won't throw an IndexError and therefore a ray ending at the boundary of the image is not ingored.

@soumyajit700
Copy link

Hi, i am getting memory error when trying to run this code in python. This function

def _find_letters( swt, shapes, shape_h, shape_w):

STEP: Discard shapes that are probably not letters

swts = []
heights = []
widths = []
topleft_pts = []
images = []

for label,layer in shapes.items():
    (nz_y, nz_x) = (layer[0],layer[1])
    east, west, south, north = max(nz_x), min(nz_x), max(nz_y), min(nz_y)
    width, height = east - west, south - north

    if width < 4 or height < 4:
        continue

    if width / height > 10 or height / width > 10:
        continue

    diameter = math.sqrt(width * width + height * height)
    median_swt = np.median(swt[(nz_y, nz_x)])
    swts.append([math.log(median_swt, 2)])
    heights.append([math.log(height, 2)])
    topleft_pts.append(np.asarray([north, west]))
    widths.append(width)
     
    fulllayer = np.zeros((shape_w, shape_h), dtype=np.uint16)
    for i in range(len(layer[0])):
        fulllayer[layer[0][i], layer[1][i]] = 1
    images.append(fulllayer)

return swts, heights, widths, topleft_pts, images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants