Changeset 3448


Ignore:
Timestamp:
12/06/07 13:33:38 (12 years ago)
Author:
melissa
Message:

Scale thumbnails in series chooser if "Autoscale images" is checked.

Location:
trunk/loci
Files:
3 edited

Legend:

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

    r3278 r3448  
    14911491  } 
    14921492 
     1493  /** Perform autoscaling on the given BufferedImage. */ 
     1494  public static BufferedImage autoscale(BufferedImage img) { 
     1495    byte[][] pixels = getPixelBytes(img, true); 
     1496    double min = Double.MAX_VALUE; 
     1497    double max = 0.0; 
     1498    int bits = pixels[0].length / (img.getWidth() * img.getHeight()) * 8; 
     1499    for (int i=0; i<pixels.length; i++) { 
     1500      Double[] mm = scanData(pixels[0], bits, true); 
     1501      double tmin = mm[0].doubleValue(); 
     1502      double tmax = mm[1].doubleValue(); 
     1503      if (tmin < min) min = tmin; 
     1504      if (tmax > max) max = tmax; 
     1505    } 
     1506 
     1507    return autoscale(img, (int) min, (int) max); 
     1508  } 
     1509 
    14931510  /** 
    14941511   * Perform autoscaling on the given BufferedImage; 
  • trunk/loci/plugins/ImporterOptions.java

    r3431 r3448  
    3232import java.awt.event.ItemEvent; 
    3333import java.awt.event.ItemListener; 
     34import java.awt.image.BufferedImage; 
    3435import java.util.*; 
    3536import javax.swing.Box; 
     
    613614        int ndx = r.getIndex(z, 0, t); 
    614615        try { 
    615           ImageIcon icon = new ImageIcon(r.openThumbImage(ndx)); 
     616          BufferedImage img = r.openThumbImage(ndx); 
     617          if (isAutoscale()) img = ImageTools.autoscale(img); 
     618          ImageIcon icon = new ImageIcon(img); 
    616619          p[i].removeAll(); 
    617620          p[i].add(new JLabel(icon)); 
     
    625628    if (forceThumbnails) gd.showDialog(); 
    626629    else { 
    627       ThumbLoader loader = new ThumbLoader(r, p, gd); 
     630      ThumbLoader loader = new ThumbLoader(r, p, gd, isAutoscale()); 
    628631      gd.showDialog(); 
    629632      loader.stop(); 
  • trunk/loci/plugins/ThumbLoader.java

    r3015 r3448  
    3636import loci.formats.FormatException; 
    3737import loci.formats.IFormatReader; 
     38import loci.formats.ImageTools; 
    3839 
    3940/** 
     
    5253  private Panel[] p; 
    5354  private Dialog dialog; 
     55  private boolean scale; 
    5456  private boolean stop; 
    5557  private Thread loader; 
     
    6365   * @param dialog the dialog containing the panels 
    6466   */ 
    65   public ThumbLoader(IFormatReader ir, Panel[] p, Dialog dialog) { 
     67  public ThumbLoader(IFormatReader ir, Panel[] p, Dialog dialog, boolean scale) 
     68  { 
    6669    this.ir = ir; 
    6770    this.p = p; 
    6871    this.dialog = dialog; 
     72    this.scale = scale; 
    6973    loader = new Thread(this, "BioFormats-ThumbLoader"); 
    7074    loader.start(); 
     
    114118        int ndx = ir.getIndex(z, 0, t); 
    115119        BufferedImage thumb = ir.openThumbImage(ndx); 
     120        if (scale) thumb = ImageTools.autoscale(thumb); 
    116121        ImageIcon icon = new ImageIcon(thumb); 
    117122        p[ii].removeAll(); 
Note: See TracChangeset for help on using the changeset viewer.