FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   pixel sort algorithm
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: pixel sort algorithm  (Read 229 times)
matthias


pixel sort algorithm
« on: Nov 28th, 2004, 2:08am »

Hi,
 
I try to sort the pixels of each frame of a webcam imput. And I'm using this sort algorith:
 
void mysort(int[] a) {
  int n = a.length;
  for (int i=0; i<n-1; i++) {
    for (int j=0; j<n-1-i; j++)
    if (green(a[j+1]) < green(a[j])) {  
 int tmp = a[j];    
 a[j] = a[j+1];
 a[j+1] = tmp;
    }
  }
}
 
but that's too slow. And the sort() of processing is not "clean" enough for what I'm trying to do. Is there somebody who has a faster one? Or any ideas? Thanks a lot. best M.
 
Pages: 1 

« Previous topic | Next topic »