BiasValImage.cpp

Go to the documentation of this file.
00001 /*! @file Qt/BiasValImage.cpp widget for display submap and updating bias */
00002 
00003 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Qt/BiasValImage.cpp $
00004 // $Id: BiasValImage.cpp 10794 2009-02-08 06:21:09Z itti $
00005 
00006 
00007 /****************************************************************************
00008  ** ui.h extension file, included from the uic-generated form implementation.
00009  **
00010  ** If you want to add, delete, or rename functions or slots, use
00011  ** Qt Designer to update this file, preserving your code.
00012  **
00013  ** You should not define a constructor or destructor in this file.
00014  ** Instead, write your code in functions called init() and destroy().
00015  ** These will automatically be called by the form's constructor and
00016  ** destructor.
00017  *****************************************************************************/
00018 
00019 #include "BiasValImage.h"
00020 #include "Image/ShapeOps.H"
00021 
00022 BiasValImage::BiasValImage(ComplexChannel& cc, SingleChannel &sc, int submap, QWidget *parent):
00023    QWidget(parent, 0), itsCC(cc), itsSC(sc), itsSubmap(submap), itsShowRaw(true), itsResizeToSLevel(true){
00024 
00025       QVBoxLayout* vlayout = new QVBoxLayout(this);
00026 
00027       //add the imageDisp, label and the bias set/get spin box
00028       itsSubmapDisp = new ImageCanvas(this);
00029       //set the image
00030       Image<float> img;
00031 
00032       if (itsSubmap != -1 ) { //single submaps
00033         if (itsShowRaw)
00034         {
00035           img = sc.getRawCSmap(itsSubmap);
00036           if (itsResizeToSLevel)
00037           {
00038             Dims mapDims = sc.getSubmap(0).getDims();
00039             // resize submap to fixed scale if necessary:
00040             if (img.getWidth() > mapDims.w())
00041               img = downSize(img, mapDims);
00042             else if (img.getWidth() < mapDims.w())
00043               img = rescale(img, mapDims);
00044           }
00045 
00046 
00047         } else {
00048           img = sc.getSubmap(itsSubmap);
00049         }
00050       } else { //combined submaps
00051         img = sc.getOutput();
00052       }
00053 
00054       //inplaceNormalize(img, 0.0F, 255.0F);
00055       //Image<PixRGB<byte> > colImg = toRGB(img);
00056       itsSubmapDisp->setImage(img);
00057       vlayout->addWidget(itsSubmapDisp);
00058 
00059       QString txtMsg;
00060       if (itsSubmap != -1 ) //single submap
00061          txtMsg = QString("Submap %1 weight").arg(itsSubmap);
00062       else
00063          txtMsg = QString("Total weight");
00064 
00065       QHBoxLayout* hlayout = new QHBoxLayout();
00066       QLabel* label = new QLabel(txtMsg, this);
00067       hlayout->addWidget(label);
00068 
00069       itsBiasVal = new QSpinBox( this);
00070       if (itsSubmap != -1 ) { //single submaps
00071          unsigned int clev = 0, slev = 0;
00072          sc.getLevelSpec().indexToCS(itsSubmap, clev, slev);
00073          LFATAL("FIXME");
00074          //itsBiasVal->setValue(int(sc.getCoeff(clev, slev)));
00075       } else { //combined submaps
00076          itsBiasVal->setValue(int(cc.getSubchanTotalWeight(sc)));
00077       }
00078 
00079 
00080       hlayout->addWidget( itsBiasVal );
00081 
00082       vlayout->addLayout( hlayout );
00083 
00084       //add the signal and slot for spin box
00085       connect( itsBiasVal, SIGNAL( valueChanged(int) ),
00086             this, SLOT( updateBias(int) ) );
00087    }
00088 
00089 void BiasValImage::updateBias(int val){
00090 
00091 
00092    //update the coeff and the display
00093 
00094    Image<float> img;
00095    if (itsSubmap != -1 ){ //submaps
00096      unsigned int clev = 0, slev = 0;
00097      itsSC.getLevelSpec().indexToCS(itsSubmap, clev, slev);
00098          LFATAL("FIXME");
00099          //     itsSC.setCoeff(clev, slev, double(val));
00100      if (itsShowRaw)
00101      {
00102        img = itsSC.getRawCSmap(itsSubmap);
00103        if (itsResizeToSLevel)
00104        {
00105          Dims mapDims = itsSC.getSubmap(0).getDims();
00106          // resize submap to fixed scale if necessary:
00107          if (img.getWidth() > mapDims.w())
00108            img = downSize(img, mapDims);
00109          else if (img.getWidth() < mapDims.w())
00110            img = rescale(img, mapDims);
00111        }
00112 
00113 
00114      } else {
00115        img = itsSC.getSubmap(itsSubmap);
00116      }
00117    } else { //combined submaps
00118      itsCC.setSubchanTotalWeight(itsSC, double(val));
00119      img = itsSC.getOutput();
00120    }
00121 
00122    //inplaceNormalize(img, 0.0F, 255.0F);
00123    //Image<PixRGB<byte> > colImg = toRGB(img);
00124    itsSubmapDisp->setImage(img);
00125 
00126 
00127    //signal the update of the single channel output
00128    //If we are the combined output, then dont signal
00129    if (itsSubmap != -1)
00130       emit updateOutput();
00131 }
00132 
00133 
00134 void BiasValImage::updateValues()
00135 {
00136 
00137    //update the coeff and the display
00138    Image<float> img;
00139    if (itsSubmap != -1 ) { //submaps
00140       unsigned int clev = 0, slev = 0;
00141       itsSC.getLevelSpec().indexToCS(itsSubmap, clev, slev);
00142       LFATAL("FIXME");
00143       //      itsBiasVal->setValue(int(itsSC.getCoeff(clev, slev)));
00144       if (itsShowRaw)
00145       {
00146         img = itsSC.getRawCSmap(itsSubmap);
00147         if (itsResizeToSLevel)
00148         {
00149           Dims mapDims = itsSC.getSubmap(0).getDims();
00150           // resize submap to fixed scale if necessary:
00151           if (img.getWidth() > mapDims.w())
00152             img = downSize(img, mapDims);
00153           else if (img.getWidth() < mapDims.w())
00154             img = rescale(img, mapDims);
00155         }
00156 
00157 
00158       } else {
00159         img = itsSC.getSubmap(itsSubmap);
00160       }
00161    } else {
00162      itsBiasVal->setValue(int(itsCC.getSubchanTotalWeight(itsSC)));
00163      img = itsSC.getOutput();
00164    }
00165 
00166 
00167    //inplaceNormalize(img, 0.0F, 255.0F);
00168    // Image<PixRGB<byte> > colImg = toRGB(img);
00169    itsSubmapDisp->setImage(img);
00170 
00171 
00172    //signal the update of the single channel output
00173    //If we are the combined output, then dont signal
00174    if (itsSubmap != -1)
00175       emit updateOutput();
00176 
00177 
00178 }
00179 
00180 
00181 void BiasValImage::setShowRaw(bool val)
00182 {
00183   itsShowRaw = val;
00184 }
00185 
00186 void BiasValImage::setResizeToSLevel(bool val)
00187 {
00188   itsResizeToSLevel = val;
00189 }
00190 
Generated on Sun May 8 08:05:33 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3