- ๐ป All of my projects are available here
- ๐จโ All of my gists are available here
- ๐ฌ Ask me about anything
- ๐ซ How to reach me [email protected]
Image compression program using quadtrees in python.
Your code is working just as you have described it. However, I was looking to perform quadtree-compression on the objects present in an image. So let's say if an image consists of a table and a chair, and I would like to perform quadtree-compression such that the depth for chair is less than the depth for table, is there a way to do it?
Presently, the code you have written allows to change the depth of complete image. Can you share a script that would allow to choose the specific pixels with in the image for performing quadtree-compression with a depth value of our choice?
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.