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

Issue when segmenting my own input #1

Open
Rini-Karumanchery opened this issue May 18, 2020 · 3 comments
Open

Issue when segmenting my own input #1

Rini-Karumanchery opened this issue May 18, 2020 · 3 comments

Comments

@Rini-Karumanchery
Copy link

Hello,
I tried to segment my own handwritten image after pre-processsing it. The segmented images were plotted in jupyter notebook, but when I tried to write it into files, I got blank files.
I tried to write the segmented images into files for the inputs you provided and also with inputs from IAM dataset and was able to write it. The code worked perfectly for inputs from IAM dataset. For some inputs which I gave the following errors were obtained:

  1. After running the code segment for #Scan the paths to see if there are any blockers.

IndexError Traceback (most recent call last)
in
71 for index, road_blocks in enumerate(road_blocks_cluster_groups):
72 window_image = nmap[:, road_blocks[0]: road_blocks[1]+10]
---> 73 binary_image[cluster_of_interest[0]:cluster_of_interest[len(cluster_of_interest)-1],:][:, road_blocks[0]: road_blocks[1]+10][int(window_image.shape[0]/2),:] *= 0

IndexError: index 0 is out of bounds for axis 0 with size 0

  1. After running the code segment for #now that everything is cleaner, its time to segment all the lines using the A* algorithm

IndexError Traceback (most recent call last)
in
5 path = np.array(astar(nmap, (int(nmap.shape[0]/2), 0), (int(nmap.shape[0]/2),nmap.shape[1]-1)))
6 offset_from_top = cluster_of_interest[0]
----> 7 path[:,0] += offset_from_top
8 line_segments.append(path)

IndexError: too many indices for array

Can you please help

@sthakurvitwo
Copy link

I am also getting the same error, can you please help?

@SaniDutta36
Copy link

#now that everything is cleaner, its time to segment all the lines using the A* algorithm

line_segments = []
for i, cluster_of_interest in enumerate(hpp_clusters):
    nmap = binary_image[cluster_of_interest[0]:cluster_of_interest[len(cluster_of_interest)-1],:]
    path = np.array(astar(nmap, (int(nmap.shape[0]/2), 0), (int(nmap.shape[0]/2),nmap.shape[1]-1)))
    if len(path) > 0:
        offset_from_top = cluster_of_interest[0]
        path[:,0] += offset_from_top
        line_segments.append(path)

Modified Code for Second ERROR

@SaniDutta36
Copy link

SaniDutta36 commented Jun 10, 2022

binary_image = get_binary(img)

for cluster_of_interest in hpp_clusters:
    nmap = binary_image[cluster_of_interest[0]:cluster_of_interest[-1],:]
    road_blocks = get_road_block_regions(nmap)
    road_blocks_cluster_groups = group_the_road_blocks(road_blocks)
    #create the doorways
    val = 10
    for index, road_blocks in enumerate(road_blocks_cluster_groups):
        window_image = nmap[:, road_blocks[0]: road_blocks[1]+val]
        window_image *= 0
        binary_image[cluster_of_interest[0]:cluster_of_interest[-1],:][:, road_blocks[0]: road_blocks[1]+val] = window_image

I made these changes on the bottom section of the corresponding code cell.... First ERROR as Mentioned by @Rini-Karumanchery is gone.... And also got output....

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

No branches or pull requests

3 participants