Changeset 7740 for trunk/projects


Ignore:
Timestamp:
08/29/11 12:02:07 (8 years ago)
Author:
aivar
Message:

Misc. changes; took out fakeData and some debugging print outs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java

    r7699 r7740  
    4545import java.awt.Canvas; 
    4646import java.awt.Color; 
    47 import java.awt.Component; 
    4847import java.awt.Rectangle; 
    49 import java.awt.event.FocusEvent; 
    50 import java.awt.event.FocusListener; 
    5148import java.util.ArrayList; 
    5249import java.util.prefs.Preferences; 
     
    222219        if (showFileDialog(getFileFromPreferences())) { 
    223220            m_image = loadImage(m_file); 
     221            if (null == m_image) { 
     222                System.out.println("image is null"); 
     223            } 
    224224            if (getImageInfo(m_image)) { 
    225225                saveFileInPreferences(m_file); 
     
    488488 
    489489    private Image<T> loadImage(String file) { 
     490        boolean threwException = false; 
    490491        ImageOpener imageOpener = new ImageOpener(); 
    491492        Image<T> image = null; 
     
    493494            image = imageOpener.openImage(file); 
    494495        } 
    495         catch (Exception e) { 
    496             System.out.println("Error " + e.getMessage()); 
     496        catch (java.io.IOException e) { } 
     497        catch (loci.formats.FormatException e) { 
     498            System.out.println("Exception message: " + e.getMessage()); 
     499            threwException = true; 
     500        } 
     501        if (null == image && !threwException) { 
     502            System.out.println("imageOpener returned null image"); 
    497503        } 
    498504        return image; 
     
    500506    
    501507    private boolean getImageInfo(Image<T> image) { 
    502         System.out.println("Image is " + image); 
    503508        int[] dimensions = new int[0]; 
    504509        try { 
     
    585590        return true; 
    586591    } 
    587  
    588     /** 
    589      * This routine creates an artificial set of data that is useful to test fitting. 
    590      * 
    591      * @return whether successful 
    592      */ 
    593    /* private boolean fakeData() { 
    594         m_width = 50; 
    595         m_height = 50; 
    596         m_timeBins = 20; 
    597         m_channels = 1; 
    598         m_timeRange = 10.0f; 
    599         m_minWave = 400; 
    600         m_waveStep = 10; 
    601  
    602         double A; 
    603         double lambda; 
    604         double b = 1.0; 
    605  
    606         // show colorized lifetimes 
    607         DataColorizer dataColorizer = new DataColorizer(m_width, m_height, "Fake Data"); 
    608         //ImageProcessor imageProcessor = new ColorProcessor(m_width, m_height); 
    609         //ImagePlus imagePlus = new ImagePlus("Fake Data", imageProcessor); 
    610  
    611         m_data = new int[m_channels][m_height][m_width][m_timeBins]; 
    612         for (int y = 0; y < m_height; ++y) { 
    613             A = 1000.0 + y  * 10000.0; // was 1000.0; bumped up Tuesday July 27 trying to get Barber LMA to work - didn't help. 
    614             for (int x = 0; x < m_width; ++x) { 
    615                 double tmpX = x; 
    616                 lambda = 0.05 + x * 0.0005d; //0.0001 + x * .001; //0.5 + x * 0.01; // .002500 + x * .01; 
    617                 //System.out.println("lambda " + lambda + " color " + lambdaColorMap(MAXIMUM_LAMBDA, lambda)); 
    618                 dataColorizer.setData(true, x, y, lambda); 
    619                 //imageProcessor.setColor(lifetimeColorMap(MAXIMUM_LIFETIME, lambda)); 
    620                 //imageProcessor.drawPixel(x, y); 
    621                 for (int t = 0; t < m_timeBins; ++t) { 
    622                     m_data[0][y][x][t] = (int)(A * Math.exp(-lambda * m_timeRange * t) + b); 
    623                 } 
    624                 //System.out.print(" " + m_data[0][y][x][0]); 
    625                 if (5 == x && 5 == y) System.out.println("at (5, 5) A is " + A + " lambda " + lambda + " b " + b); 
    626                 if (10 == x && 10 == y) System.out.println("at (10, 10) A is " + A + " lambda " + lambda + " b " + b); 
    627                 if (49 == x && 49 == y) System.out.println("at (49, 49) A is " + A + " lambda " + lambda + " b " + b); 
    628             } 
    629             //System.out.println(); 
    630         } 
    631         dataColorizer.update(); 
    632         return true; 
    633     } 
    634     */ 
    635592 
    636593    /** 
     
    856813            double lifetime = dataArray[dataIndex].getParams()[3]; 
    857814 
    858             System.out.println("lifetime is " + lifetime); 
    859             System.out.println("min " + min + " max " + max); 
    860             System.out.println("color is " + lifetimeColorMap(min,max, lifetime)); 
    861              
    862815            imageProcessor.setColor(lifetimeColorMap(min, max, lifetime)); 
    863816 
     
    11341087        long elapsed = System.nanoTime() - start; 
    11351088        System.out.println("nanoseconds " + elapsed); 
     1089        showRunningAverage(elapsed); 
    11361090 
    11371091        return m_fittedImage; 
     1092    } 
     1093 
     1094    static int s_avgIndex; 
     1095    static ArrayList<Long> s_list = new ArrayList<Long>(); 
     1096 
     1097    private void showRunningAverage(long elapsed) { 
     1098        s_list.add(elapsed); 
     1099        long total = 0; 
     1100        for (long time : s_list) { 
     1101            total += time; 
     1102        } 
     1103        total /= s_list.size(); 
     1104        System.out.println("average " + total + " after " + s_list.size() + " trials"); 
    11381105    } 
    11391106 
     
    12071174        int dim[]; 
    12081175        if (m_hasChannels) { 
    1209             dim = new int[] { x, y, bin, channel }; 
     1176            dim = new int[] { x, y, bin, channel }; //TODO ARG is this order guaranteed? 
    12101177        } 
    12111178        else { 
Note: See TracChangeset for help on using the changeset viewer.