Noob trying to create gradients from an image
              in 
             Programming Questions 
              •  
              2 years ago    
            
 
           
             Hi all,
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
             
              
             
             
              
             
             
              
             
             
              
             
             
                
             
             
                
             
             
              
             
             
               
             
             
                
             
             
                
             
             
              
             
              
           
 
            
           
             I'm just getting going with Processing and want to create a gradient with the individual pixels of an image.  I've got it to the point where it's sort of working.  The result is close to a gradient but there are inconsistencies as you can see.  I think I'm misunderstanding the color datatype or pixel[].  Any help would be great.
            
            
              PImage images;
             
             
              PImage img = createImage(400,300, RGB);
             
             
              void setup() {
             
             
                size(400, 300);
             
             
                images = loadImage("DSCF1166.JPG");
             
             
                images.loadPixels();
             
             
                img.loadPixels();
             
             
                noLoop();
             
             
              }
             
             
              void draw() {
             
             
                color[] test = sort(images.pixels);
             
             
                for(int i = 0; i <= 119999; i++) {
             
             
                    println(test[i]);
             
             
                    img.pixels[i] = test[i];
             
             
                }
             
             
                img.updatePixels();
             
             
                image(img, 0,0);  
             
             
              }
             
             
              
              1  
            
 
            