title: How to open an image with ImageJ in java
body: <p>I want to analyse images using the ImageJ framework in java. How can I open an image? I need to have an <code>ImageProcessor</code> object to be able to generate a histogram. Here is the code I have so far:</p>
  
  <pre><code>public void run(ImageProcessor ip) {
          int[] H = new int[256]; // histogram array
          int w = ip.getWidth();
          int h = ip.getHeight();
  
          for (int v = 0; v &lt; h; v++) {
              for (int u = 0; u &lt; w; u++) {
                  int i = ip.getPixel(u, v);
                  H[i] = H[i] + 1;
              }
          }
  
          // ... histogram H[] can now be used
      }
  </code></pre>