Giter Site home page Giter Site logo

quasimondo / rasterfairy Goto Github PK

View Code? Open in Web Editor NEW
278.0 278.0 36.0 61.14 MB

The purpose of Raster Fairy is to transform any kind of 2D point cloud into a regular raster whilst trying to preserve the neighborhood relations that were present in the original cloud. A typical use case is if you have a similarity clustering of images and want to show the images in a regular table structure.

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

rasterfairy's People

Contributors

flhorizon avatar fr1ll avatar genekogan avatar pechyonkin avatar quasimondo avatar staticskies 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  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  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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rasterfairy's Issues

AttributeError: module 'rasterfairy' has no attribute 'getRectArrangements'

I tried one of your examples, the first one to be precise (Raster Fairy - Random Swap Optimization Demo.ipynb), and it all works fine until I get to the command arrangements = rasterfairy.getRectArrangements(totalDataPoints).
When python tries to execute this line it stops with the error:
AttributeError: module 'rasterfairy' has no attribute 'getRectArrangements'

I have no clue why, but it seems that it can't see any of the functions defined in the class.

stackblur question

apologies for using an issue on an unrelated repo, but your website doesn't appear to have any contact information, and https://www.npmjs.com/package/stackblur doesn't link to a github repo, so: if that yours? If so, would it be possible to put up the repo and webpage for it again, and tell npm what the repo URL is? Because it appears to be the only dedicated "just blur an array" package out there, and having a place to examine the code would be super valuable.

add citation example

Hi Mario,

I'm sorry if this is not the best place to ask. But I've been looking for the best way to cite your work in a scientific paper. I found one example here:

Mario Klingemann. 2015. RasterFairy. https://github.com/Quasimondo/RasterFairy

If that is Ok, I would suggest adding in your MD file: "If you are using this work in a scientific publication, cite as Mario Klingemann. 2015. RasterFairy. https://github.com/Quasimondo/RasterFairy"

BTW, your work is amazing and I believe it will be usefull in several scientific fields. Thank you!

Rasterfairy fails if no target is set, hangs if wrong target is set

Hey, thanks for the great library!

I've been getting some weird issues. First, if target isn't set, it looks like theres a dependency on a lib called prime that doesn't exist. Second, if target is set to a specific number, sometimes rasterfairy will hang (depending on the number of points that are being transformed).

For the latter, if I have 65 points and try a target of 8 x 9, it hangs forever.

Am I missing settings that could cause this? Or is this an actual bug?

Thanks!

Error "slice indices must be integers or None or have an __index__ method"

Hi Mario

first of all: thanks for RasterFairy. Very much appreciated!

I can install and use RasterFairy with Python 2.7. Unfortunately I get this error when I try to to use it with v3.5 (trying to follow Gene Kogans TSNE notebooks with Keras, TF1.0). I am using a conda environment on Windows 10.

Any idea what might be the cause and how to fix this?

Many thanks in advance.

<ipython-input-28-842e2c585a53> in <module>()
      6 
      7 # assign to grid
----> 8 grid_assignment = rasterfairy.transformPointCloud2D(tsne, target=(nx, ny))

H:\KI\keras\rasterfairy.py in transformPointCloud2D(points2d, target, autoAdjustCount, proportionThreshold)
    107         if ( len(quadrants[i]['points']) > 1 ):
    108             slices = sliceQuadrant(quadrants[i], mask = rasterMask)
--> 109             if len(slices)>1:
    110                 del quadrants[i]
    111                 quadrants += slices

H:\KI\keras\rasterfairy.py in sliceQuadrant(quadrant, mask)
    170             order = np.lexsort((xy[:,0],xy[:,1]))
    171             sliceCount = sliceYCount
--> 172             sliceSize = grid[3] / sliceCount
    173             pointsPerSlice = grid[2] * sliceSize
    174             gridOffset = grid[1]

TypeError: slice indices must be integers or None or have an __index__ method```

Python 3 compat + adding to PyPi?

Hi @Quasimondo,

I am a big fan of your work!

I have been using rasterfairy for 2 years to make grids of images.
I'm open sourcing a method that uses rasterfairy for Python 3. Would it make sense to create a branch or something with Python 3 compat?

Also it would be really nice to get this on PyPi, I am happy to do this if you're on to bigger and better things.

How to label data?

Not exactly an issue, more of a question that I can't figure out from your demos: when running transformPointCloud2D() does the order of points in the array stay the same as the original? In other words, if I have a numpy array of my data and another with labels, will they still correlate after the transformation?

Banded/divided grid layout

Mario! RasterFairy is so great, and I'm using it to lay out about 140k images right now. I seem to be getting some weird results though:

screen shot 2017-07-12 at 6 16 22 pm

Note the banding and the stark dividing line in the middle. It's possible that the problem is my visualizing code, but it's pretty straightforward – have you run into anything like this before?

Unexpected horizontal 'lines'

Many thanks for this library, Mario! This effort is much appreciated.

I am surprised by the results I got today for a little holiday art project I am working on.

The UMAP embeddings for my test case (just the letter 'A' embedded) look like this:
image

However, after a RasterFairy processing, the grid image shows horizontal stripes, here a small section (but along the full width of the image):
image

What is the cause of these horizontal stripes? Are there libraries that prevent these from occurring (note that these stripes are not present in the original UMAP embeddings). I would expected 2D blobs of similar images, just like in the demo animation in this repo.

glitchy/blocky output

i'm still working with this cloud-to-grid problem, and wanted to understand rasterfairy a little better because it's so fast for larger datasets. but i'm having trouble getting smooth output. i generated some toy data:

import numpy as np
side = 85
n = side * side
np.random.seed(0)
lhs = np.random.uniform(low=-1, high=+1, size=(n, 2))
lhs = np.cumsum(lhs, axis=0)
lhs -= lhs.min(axis=0)
lhs /= lhs.max(axis=0)
lhs *= (side - 1)

the output from rasterfairy looks like this:

download-4

while a linear assignment solver shows the optimum is:

download-2

is there any way to get a better result out of rasterfairy, or is this "blocky" solution part of the algorithm? with some linear assignment algorithms there are "approximation" knobs that let you tune the run time vs solution accuracy, and i was wondering if rasterfairy has something similar i could tweak.

getRectArrangements returns poor results for some square numbers

import rasterfairy
for side in range(4, 100):
    n = side*side
    best = rasterfairy.getRectArrangements(n)[0]
    if side != best[0]:
        print(side, best)

i would expect this to print nothing, because getRectArrangements should quickly find that there is a square available. instead, it prints:

not enough memory for amount of possible permutations, creating grouped set
not enough memory for amount of possible permutations, creating grouped set
48 (36, 64)
not enough memory for amount of possible permutations, creating grouped set
not enough memory for amount of possible permutations, creating grouped set
72 (64, 81)
not enough memory for amount of possible permutations, creating grouped set
80 (64, 100)
not enough memory for amount of possible permutations, creating grouped set
96 (72, 128)

this makes me skeptical that it's generally finding the best solution.

here is an alternative implementation that i use, it finds the rectangle that is closest to a square:

import math
def find_rectangle(n): 
    max_side = int(math.sqrt(n))
    for h in range(2, max_side+1)[::-1]:
        w = n // h
        if (h * w) == n:
            return (h, w)
    return (n, 1)

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.