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

ZeroDivisionError: division by zero for a given image #2

Open
aradhyamathur opened this issue Jan 15, 2024 · 0 comments
Open

ZeroDivisionError: division by zero for a given image #2

aradhyamathur opened this issue Jan 15, 2024 · 0 comments

Comments

@aradhyamathur
Copy link

aradhyamathur commented Jan 15, 2024

test_q
for this particular image i get a zero division error while calculating the average color.

Cell In[25], [line 99](vscode-notebook-cell:?execution_count=25&line=99)
     [96](vscode-notebook-cell:?execution_count=25&line=96) root.split_quadrant(image)
     [98](vscode-notebook-cell:?execution_count=25&line=98) for children in root.children:
---> [99](vscode-notebook-cell:?execution_count=25&line=99)     self.build(children, image)

Cell In[25], [line 96](vscode-notebook-cell:?execution_count=25&line=96)
     [93](vscode-notebook-cell:?execution_count=25&line=93)     return 
     [95](vscode-notebook-cell:?execution_count=25&line=95) # split quadrant if there is too much detail
---> [96](vscode-notebook-cell:?execution_count=25&line=96) root.split_quadrant(image)
     [98](vscode-notebook-cell:?execution_count=25&line=98) for children in root.children:
     [99](vscode-notebook-cell:?execution_count=25&line=99)     self.build(children, image)

Cell In[25], [line 61](vscode-notebook-cell:?execution_count=25&line=61)
     [58](vscode-notebook-cell:?execution_count=25&line=58) middle_y = top + (height - top) / 2
     [60](vscode-notebook-cell:?execution_count=25&line=60) # split root quadrant into 4 new quadrants
---> [61](vscode-notebook-cell:?execution_count=25&line=61) upper_left = Quadrant(image, (left, top, middle_x, middle_y), self.depth+1)
     [62](vscode-notebook-cell:?execution_count=25&line=62) upper_right = Quadrant(image, (middle_x, top, width, middle_y), self.depth+1)
     [63](vscode-notebook-cell:?execution_count=25&line=63) bottom_left = Quadrant(image, (left, middle_y, middle_x, height), self.depth+1)

Cell In[25], [line 51](vscode-notebook-cell:?execution_count=25&line=51)
     [48](vscode-notebook-cell:?execution_count=25&line=48) hist = image.histogram()
     [50](vscode-notebook-cell:?execution_count=25&line=50) self.detail = get_detail(hist)
---> [51](vscode-notebook-cell:?execution_count=25&line=51) self.colour = average_colour(image)

Cell In[25], [line 14](vscode-notebook-cell:?execution_count=25&line=14)
     [11](vscode-notebook-cell:?execution_count=25&line=11) image_arr = np.asarray(image)
     [13](vscode-notebook-cell:?execution_count=25&line=13) # get average of whole image
---> [14](vscode-notebook-cell:?execution_count=25&line=14) avg_color_per_row = np.average(image_arr, axis=0)
     [15](vscode-notebook-cell:?execution_count=25&line=15) avg_color = np.average(avg_color_per_row, axis=0) 
     [17](vscode-notebook-cell:?execution_count=25&line=17) return (int(avg_color[0]), int(avg_color[1]), int(avg_color[2]))

it seems like the quadrant is of shape (3,) which I could not understand why, can you please guide ?

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

1 participant