├── LICENSE ├── README.md ├── exampleImages ├── cat.jpg └── cat2.jpg ├── exampleResults ├── cat2Result.jpg ├── catResult.jpg ├── reactiondiffusion1.png ├── reactiondiffusion2.png ├── scribble.jpg └── scribble2.jpg ├── randomLines └── randomLines.pde ├── reactionDiffusion └── reactionDiffusion.pde └── scribbleLines └── scribbleLines.pde /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 bleeptrack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # scribbleplot 2 | collection of my processing sketches used for transforming images to artsy plottable images (jpg/vector). Here are some output examples: 3 | 4 | # randomLines [jpg,pdf] 5 | ![stylized image of cat](exampleResults/catResult.jpg) 6 | ![stylized image of cat](exampleResults/cat2Result.jpg) 7 | 8 | # scribbleLines [jpg,pdf] 9 | ![stylized image of cat](exampleResults/scribble.jpg) 10 | ![stylized image of cat](exampleResults/scribble2.jpg) 11 | 12 | # reactionDiffusion [png, needs to be vectorized] 13 | ![stylized image of cat](exampleResults/reactiondiffusion1.png) 14 | ![stylized image of cat](exampleResults/reactiondiffusion2.png) 15 | 16 | 17 | -------------------------------------------------------------------------------- /exampleImages/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleImages/cat.jpg -------------------------------------------------------------------------------- /exampleImages/cat2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleImages/cat2.jpg -------------------------------------------------------------------------------- /exampleResults/cat2Result.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleResults/cat2Result.jpg -------------------------------------------------------------------------------- /exampleResults/catResult.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleResults/catResult.jpg -------------------------------------------------------------------------------- /exampleResults/reactiondiffusion1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleResults/reactiondiffusion1.png -------------------------------------------------------------------------------- /exampleResults/reactiondiffusion2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleResults/reactiondiffusion2.png -------------------------------------------------------------------------------- /exampleResults/scribble.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleResults/scribble.jpg -------------------------------------------------------------------------------- /exampleResults/scribble2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bleeptrack/scribbleplot/13b6d5dea09a937c3b458fc366e1e7ae1401a0e4/exampleResults/scribble2.jpg -------------------------------------------------------------------------------- /randomLines/randomLines.pde: -------------------------------------------------------------------------------- 1 | import processing.pdf.*; 2 | 3 | //change these parameters as you want :) 4 | //pdf gets saved automatically 5 | //click to safe jpg 6 | //press any key to redraw image 7 | 8 | //size of each scribbly block in the finished image 9 | int s = 9; 10 | 11 | //number of pixels lines are allowed to expand into the neighour blocks 12 | int addon = 2; 13 | 14 | //maximum lines allowed in each block 15 | int maxlines = 30; 16 | 17 | // path/name of the file to load 18 | String filename = "../exampleImages/cat.jpg"; 19 | 20 | PImage img; 21 | float lastX = 0; 22 | float lastY = 0; 23 | float posX = 0; 24 | float posY = 0; 25 | 26 | void setup() { 27 | 28 | img = loadImage(filename); 29 | 30 | size(800, 600); 31 | surface.setResizable(true); 32 | surface.setSize(img.width, img.height); 33 | redraw(); 34 | noLoop(); 35 | 36 | beginRecord(PDF, "scribble.pdf"); 37 | } 38 | 39 | void mousePressed(){ 40 | saveFrame("scribble.jpg"); 41 | } 42 | 43 | void keyPressed(){ 44 | redraw(); 45 | } 46 | 47 | 48 | void draw() { 49 | 50 | stroke(0); 51 | background(255); 52 | //image(img, 0, 0); 53 | for(int windowX = s/2+1; windowX+s/2< img.width; windowX += s){ 54 | for(int windowY = s/2+1; windowY+s/2 < img.height; windowY += s){ 55 | update(windowX,windowY); 56 | drawBlock(windowX,windowY,s,addon); 57 | 58 | //println(windowX + " "+ windowY); 59 | 60 | } 61 | } 62 | 63 | endRecord(); 64 | } 65 | 66 | int loc(int x, int y){ 67 | return x + y*img.width; 68 | } 69 | 70 | float brit(int x, int y){ 71 | int pos = loc(x,y); 72 | color col = img.pixels[pos]; 73 | return brightness(col); 74 | } 75 | 76 | float avgBrit(int x, int y, int s){ 77 | FloatList l = new FloatList(); 78 | for(int xi = x-s/2; xi <= x+s/2; xi++){ 79 | for(int yi = y-s/2; yi <= y+s/2; yi++){ 80 | l.append(brit(xi,yi)); 81 | } 82 | } 83 | return 255 - (l.sum()/l.size()); 84 | } 85 | 86 | void update(float lineX, float lineY){ 87 | lastX = posX; 88 | lastY = posY; 89 | posX = lineX; 90 | posY = lineY; 91 | } 92 | 93 | float randBlock(int x, int s, int a){ 94 | return random(x-s/2-a,x+s/2+a); 95 | } 96 | 97 | int getLoop(float brit){ 98 | return round(map(brit,0,255,0,maxlines)); 99 | } 100 | 101 | int getLoop(int x, int y, int s){ 102 | float brit = avgBrit(x,y,s); 103 | //println("brit " + brit + " " + x + " " + y); 104 | return round(map(brit,0,255,0,maxlines)); 105 | } 106 | 107 | void drawBlock(int x, int y, int s, int a){ 108 | int loops = getLoop(x,y,s); 109 | for(int i = 0; i1000){ 85 | minB = i; 86 | } 87 | if(maxB==256 && histogram[255-i]>1000){ 88 | maxB = 255-i; 89 | } 90 | } 91 | 92 | 93 | float kStep = (kmax-kmin)/255; 94 | float cStep = 180.0/width; 95 | float fStep = (fmax-fmin)/255; 96 | 97 | for(int i = 0; i< w; i++){ 98 | for(int j = 0; j< h; j++){ 99 | kMap[i][j] = kmax - kStep*map(brit(i,j),minB,maxB,0,255); 100 | 101 | fMap[i][j] = fmin + fStep*map(brit(i,j),minB,maxB,0,255); 102 | } 103 | } 104 | } 105 | 106 | 107 | int getcolorBW(float value){ 108 | return 255-(int)constrain(map(value,0,0.4,0,255),0,255); 109 | } 110 | 111 | 112 | void setup(){ 113 | img = loadImage(filename); 114 | size(800, 600, P2D); 115 | surface.setResizable(true); 116 | // 117 | image(img, 0, 0); 118 | colorMode(HSB,360,100,100); 119 | 120 | redraw(); 121 | 122 | w = img.width; 123 | h= img.height; 124 | dimg = new PImage(w,h); 125 | a = new float[w][h]; 126 | b = new float[w][h]; 127 | tmpA = new float[w][h]; 128 | tmpB = new float[w][h]; 129 | init(); 130 | randFeed(); 131 | noStroke(); 132 | 133 | } 134 | 135 | void randFeed(){ 136 | for(int i = 0; i< w; i++){ 137 | for(int j = 0; j< h; j++){ 138 | float r = random(0,1); 139 | if(r>0.995){ 140 | b[i][j]=1; 141 | } 142 | } 143 | } 144 | } 145 | 146 | void mouseClicked(){ 147 | saveFrame("one-"+ceil(random(0,1009))+".png"); 148 | } 149 | 150 | 151 | void draw(){ 152 | if(!resz){ 153 | surface.setSize(img.width, img.height); 154 | resz = true; 155 | } 156 | 157 | if(count>speed){ 158 | count = 0; 159 | background(255); 160 | 161 | for(int x = 0; x val, ArrayList weight){ 78 | int sum = 0; 79 | ArrayList integSum = new ArrayList(); 80 | for( int i = 0; i> map = new HashMap>(); 98 | for(int i = 0; i0 && x+i0 && y+j lst = map.get(round(brit(x+i,y+j))); 103 | if(lst == null){ 104 | lst = new ArrayList(); 105 | 106 | } 107 | 108 | if(!visited[x+i][y+j]){ 109 | lst.add(loc(x+i,y+j)); 110 | } 111 | 112 | map.put(round(brit(x+i,y+j)),lst); 113 | 114 | } 115 | 116 | } 117 | } 118 | 119 | //available brightness values 120 | Set s = map.keySet(); 121 | ArrayList ks = new ArrayList(); 122 | ks.addAll(s); 123 | Collections.sort(ks); 124 | 125 | ArrayList weights = new ArrayList(); 126 | for( int i = 0; i l = map.get(k); 135 | int r = round(random(0,l.size()-1)); 136 | 137 | visited[pointX(r)][pointY(r)] = true; 138 | 139 | return l.get(r); 140 | 141 | } 142 | 143 | void update(int lineX, int lineY){ 144 | lastX = posX; 145 | lastY = posY; 146 | posX = lineX; 147 | posY = lineY; 148 | } 149 | 150 | int loc(int x, int y){ 151 | return x + y*img.width; 152 | } 153 | 154 | int pointX(int l){ 155 | return l % img.width; 156 | } 157 | 158 | int pointY(int l){ 159 | return l / img.width; 160 | } 161 | 162 | float brit(int x, int y){ 163 | int pos = loc(x,y); 164 | color col = img.pixels[pos]; 165 | // inverting here helps for easier weighting later 166 | return 255-brightness(col)/2; 167 | } --------------------------------------------------------------------------------