Package me.kikoqiu.opencl.image

Examples of me.kikoqiu.opencl.image.IImage2d


      }
      if( hh*divider<h){
        ++hh;
      }
      w=ww;h=hh;
      IImage2d img=new ImageRGBA_SNORM_INT16();
      img.create(w, h, true);
      outputs.add(img);
    }
  }
View Full Code Here


    exec(kernel,output.getWidth(),output.getHeight());       
  }
 
  public void filter(Object ... args)
    {
    IImage2d output=(IImage2d) args[args.length-1];

    Object[] args1=new Object[args.length];
    int p=0;
    for(Object o:args){
      if(o instanceof IImage2d){
        args1[p++]=((IImage2d) o).getBuffer();       
      }else {
        args1[p++]=o;
      }
    }
   
        Kernels.setArgs(kernel, args1);
        exec(kernel,output.getWidth(),output.getHeight());     
    }
View Full Code Here

    img2.create(w, h, true);
  }
 
  public IImage2d filter(IImage2d input,int loops, Main main){
    init(input.getWidth(),input.getHeight());
    IImage2d output=img1;
    for(int i=0;i<loops;++i){
      Kernels.setArgs(kernel, input.getBuffer(), output.getBuffer());     
      exec(kernel,output.getWidth(),output.getHeight());
      input=output;
      output=input==img1?img2:img1;
    }
    return input;
  }
View Full Code Here

    BufferedImage ret=null;
    if(bi==null)return ret;   
    Profile.begin();
   
    //create current frame image and scale it
    IImage2d inputNow=new ImageRGBA();   
    inputNow.create(bi);   
    sfNow.init(inputNow.getWidth(), inputNow.getHeight(), 16, 2);
    sfNow.filter(inputNow);
       
    Profile.out();
    if(inputPrev!=null){
      IImage2d calcatedFlow=new ImageRGBA_SNORM_INT16();;
      calcatedFlow.create(1, 1, true);
      Helpers.getInstance().clear(calcatedFlow);
     
      //for all scaled images,from small to large
      for(int i=sfPrev.outputs.size()-1;i>=0;--i){
        IImage2d i1=sfPrev.outputs.get(i),i2=sfNow.outputs.get(i);
       
        //create preprocessed image
        IImage2d preprocessed=new ImageRGBA_SNORM_INT16();
        preprocessed.create(i1.getWidth(), i1.getHeight(), true);       
        preprocess.filter(i1, preprocessed)
        Profile.out("pre");
       
        IImage2d flowout=new ImageRGBA_SNORM_INT16()
        flowout.create(preprocessed.getWidth(), preprocessed.getHeight(), true);       
       
        solve.filter(i2, preprocessed,calcatedFlow,flowout);
        calcatedFlow.dispose();
       
        //iterate current level
        if(iterateCount>0){
          IImage2d flowout1=new ImageRGBA_SNORM_INT16()
          flowout1.create(preprocessed.getWidth(), preprocessed.getHeight(), true);
          IImage2d fin=flowout;
          for(int k=0;k<iterateCount;++k){
            IImage2d fnext=fin==flowout?flowout1:flowout;
            solve_k.filter(i2, preprocessed,fin,fnext);         
            fin=fnext;
          }
          IImage2d fnext=fin==flowout?flowout1:flowout;
          fnext.dispose();
          flowout=fin;
        }
       
       
       
View Full Code Here

      }
      if(ww*divider!=w || hh*divider!=h){
        break;
      }
      w=ww;h=hh;
      IImage2d img=new ImageLumi();
      img.create(w, h, true);
      outputs.add(img);
    }
  }
View Full Code Here

    }
  }
 
  public void filter(IImage2d input){
    for(IImage2d output:outputs){
      IImage2d tmp=new ImageLumi();
      tmp.create(output.getWidth(), output.getHeight()*2, true);
     
      Kernels.setArgs(kernel, input.getBuffer(), tmp.getBuffer());     
      exec(kernel,tmp.getWidth(),tmp.getHeight());     
     
     
      Kernels.setArgs(kernel_v, tmp.getBuffer(), output.getBuffer());     
      exec(kernel_v,output.getWidth(),output.getHeight());
     
      tmp.dispose();
     
      input=output;
    }
  } 
View Full Code Here

TOP

Related Classes of me.kikoqiu.opencl.image.IImage2d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.