GithubHelp home page GithubHelp logo

alpharaoh / quadtree-compression Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 5.0 17.29 MB

Image compression program using quadtrees in python.

Python 100.00%
python3 image-processing image-compression quadtree quadtree-art quadtrees

quadtree-compression's Introduction

Languages and Tools:

python java mySQL jupyter javascript typescript typescript typescript flutter reactnative redux postgresql expo gcp firebase bash linux git tensorflow opencv numpy css html5





  • ๐Ÿ’ป All of my projects are available here
  • ๐Ÿ‘จโ€ All of my gists are available here
  • ๐Ÿ’ฌ Ask me about anything
  • ๐Ÿ“ซ How to reach me [email protected]

alpharaoh

https://www.linkedin.com/in/akaam-shamerany-b3917b1a4/ https://www.instagram.com/s.akaam/ https://twitter.com/VadeEcon

alpharaoh

quadtree-compression's People

Contributors

alpharaoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

quadtree-compression's Issues

Varying the depth of quadtree within the image

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?

ZeroDivisionError: division by zero for a given image

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.