Changeset 1333


Ignore:
Timestamp:
08/23/06 13:44:14 (14 years ago)
Author:
melissa
Message:

Added a command line option to open a subset of the images:

$ showinf -range <start> <end> <file>
$ showinf -range <start> <file>

The first command will open planes from <start> to <end - 1>, and the second will open planes from <start> to getImageCount(<file>) - 1.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FormatReader.java

    r1294 r1333  
    404404    boolean separate = false; 
    405405    boolean omexml = false; 
     406    int start = 0; 
     407    int end = 0; 
    406408    if (args != null) { 
    407409      for (int i=0; i<args.length; i++) { 
     
    412414          else if (args[i].equals("-separate")) separate = true; 
    413415          else if (args[i].equals("-omexml")) omexml = true; 
     416          else if (args[i].equals("-range")) { 
     417            try { 
     418              start = Integer.parseInt(args[i + 1]); 
     419              i++; 
     420              end = Integer.parseInt(args[i + 1]); 
     421              i++; 
     422            } 
     423            catch (Exception e) { } 
     424          } 
    414425          else System.out.println("Ignoring unknown command flag: " + args[i]); 
    415426        } 
     
    425436        reader.getFormat() + " format, run:"); 
    426437      System.out.println("  java " + className + " [-nopix]"); 
    427       System.out.println("    [-merge] [-stitch] [-separate] [-omexml] file"); 
     438      System.out.println("    [-merge] [-stitch] [-separate] [-omexml] " + 
     439        "[-range start [end]] file"); 
    428440      return false; 
    429441    } 
     
    452464      reader.setSeparated(separate); 
    453465      int num = reader.getImageCount(id); 
    454  
    455       System.out.print("(" + num + ") "); 
     466      if (end == 0 || end > num) end = num; 
     467      if (end < 0) end = 0; 
     468      if (start < 0) start = 0; 
     469      if (start >= num) start = num - 1; 
     470 
     471      System.out.print("(" + (end - start) + ") "); 
    456472      long e1 = System.currentTimeMillis(); 
    457       BufferedImage[] images = new BufferedImage[num]; 
     473      BufferedImage[] images = new BufferedImage[end - start]; 
    458474      long s2 = System.currentTimeMillis(); 
    459       for (int i=0; i<num; i++) { 
    460         images[i] = reader.openImage(id, i); 
     475      for (int i=start; i<end; i++) { 
     476        images[i - start] = reader.openImage(id, i); 
    461477        System.out.print("."); 
    462478      } 
     
    466482      // output timing results 
    467483      float sec = (e2 - s1) / 1000f; 
    468       float avg = (float) (e2 - s2) / num; 
     484      float avg = (float) (e2 - s2) / (end - start); 
    469485      long initial = e1 - s1; 
    470486      System.out.println(sec + "s elapsed (" + 
  • trunk/loci/formats/ImageReader.java

    r1294 r1333  
    336336        String arg = args[i]; 
    337337        if (arg.startsWith("-")) continue; 
     338        try { 
     339          Integer.parseInt(arg); 
     340          continue; 
     341        } 
     342        catch (Exception e ) { } 
    338343        System.out.print("Checking file format "); 
    339344        System.out.println("[" + getFormat(arg) + "]"); 
Note: See TracChangeset for help on using the changeset viewer.