java - Convert an image to matrix -


i'm trying convert simple image matrix m*n, m , n width , heigth of image. @ point don't understand best way work out steps.

there code @ moment:

  public double[][] img2matriz(bufferedimage bi){     double[][] c;     for(int i=0;i<bi.getheight();i++)      {         for(int j=0;j<bi.getwidth();j++)         {             c[i][j]         }     }      }  

in [i] , [j] want put values of matrix rgb respectively.

try this:

c[i][j] = bi.getrgb(i, j); 

the getrgb() method returns integer, can bit-masked give individual components. more appropriate if c integer array, not double.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -