Exemplo n.º 1
0
vector<int> rscc::determineinput(const vector<int>& input) const
   {
   assert(input.size() == k);
   vector<int> ip = input;
   for (int i = 0; i < ip.size(); i++)
      if (ip(i) == fsm::tail)
         ip(i) = (reg(i) + bitfield(0, 1)) * gen(i, i);
   return ip;
   }
Exemplo n.º 2
0
void CFilterWaveletDlg::OnOK()
   {
   UpdateData(true);
   // set up library names
   using libbase::weight;
   using libbase::log2;
   // handle errors first
   const int nMaxLevel = int(floor(log2(m_bWholeImage ? min(m_pPSPlugIn->GetImageWidth(), m_pPSPlugIn->GetImageHeight()) : min(m_nTileX, m_nTileY)))) - 1;
   if(m_nWaveletLevel < 1 || m_nWaveletLevel > nMaxLevel)
      {
      cerr << "Invalid wavelet level (" << m_nWaveletLevel << "): must be between 1 and " << nMaxLevel << ".\n";
      return;
      }
   if(!m_bWholeImage && (m_nTileX < 8 || m_nTileY < 8))
      {
      cerr << "Invalid tile size (" << m_nTileX << "x" << m_nTileY << "): must be at least 8x8.\n";
      return;
      }
   switch(m_nThreshSelector)
      {
      case 1: // Visu
      case 0: // % of coefficients
         break;
      case 4: // Hybrid+
      case 3: // SURE
      case 2: // Minimax
      default: // unsupported type
         cerr << "Unknown threshold selector (" << m_nThreshSelector << ").\n";
         return;
      }
   // handle warnings next
   if(!m_bWholeImage && (weight(m_nTileX)!=1 || weight(m_nTileY)!=1))
      {
      CString sMessage = "Chosen tile size is not an integral power of two; this could lead to artifacts and slower operation - are you sure you want to use this value?";
      if(MessageBox(sMessage, NULL, MB_YESNO | MB_ICONWARNING) != IDYES)
         return;
      }
   // go ahead
   CDialog::OnOK();
   // convert parameters that need conversion
   m_nWaveletPar = GetDlgItemInt(IDC_WAVELET_PAR);
   trace << "Wavelet parameter converted to: " << m_nWaveletPar << "\n";
   }
Exemplo n.º 3
0
bitfield rscc::determinefeedin(const vector<int>& input) const
   {
   assert(input.size() == k);
   // check we have no 'tail' inputs
   for (int i = 0; i < k; i++)
      assert(input(i) != fsm::tail);
   // compute input junction
   bitfield sin, ip = bitfield(vector<bool>(input));
   for (int i = 0; i < k; i++)
      sin = ((reg(i) + ip.extract(i)) * gen(i, i)) + sin;
   return sin;
   }
Exemplo n.º 4
0
double awgn::pdf(const sigspace& tx, const sigspace& rx) const
   {
   sigspace n = rx - tx;
   using libbase::gauss;
   return gauss(n.i() / sigma) * gauss(n.q() / sigma);
   }
Exemplo n.º 5
0
void CFilterWaveletApp::FilterContinue(void)
   {
   // update progress counter
   DisplayTileProgress(0, 100, m_nIteration, 2);

   // set up library names
   using libbase::matrix;
   using libbase::weight;
   using libbase::log2;
   using libimage::limiter;

   // do the processing for this tile
   matrix<double> in, out;
   GetPixelMatrix(in);

   if(m_nIteration == 0)
      {
      // first iteration: update statistics
      if(weight(in.size().rows()) != 1 || weight(in.size().cols()) != 1)
         {
         matrix<double> temp(1<<int(ceil(log2(in.size().rows()))), 1<<int(ceil(log2(in.size().cols()))));
         temp = 0;
         temp.copyfrom(in);
         waveletfilter::update(temp);
         }
      else
         waveletfilter::update(in);
      }
   else
      {
      // second iteration: do the wavelet shrinkage
      if(weight(in.size().rows()) != 1 || weight(in.size().cols()) != 1)
         {
         matrix<double> temp(1<<int(ceil(log2(in.size().rows()))), 1<<int(ceil(log2(in.size().cols()))));
         temp = 0;
         temp.copyfrom(in);
         waveletfilter::process(temp, temp);
         out.init(in.size());
         out.copyfrom(temp);
         }
      else
         waveletfilter::process(in, out);

      limiter<double> lim(0,1);
      lim.process(out);
      if(m_sData->bKeepNoise)
         {
         out *= -1;
         out += in;
         out += 0.5;
         lim.process(out);
         }
      SetPixelMatrix(out);
      }

   // select the next rectangle based on the given tile suggestions
   CPSPlugIn::FilterContinue();
   // if we need to do a second iteration
   if(m_nIteration==0 && IterationDone())
      {
      // update iteration counter & restart from first tile
      m_nIteration++;
      IterationStart();
      // compute threshold from gathered statistics
      waveletfilter::estimate();
      }
   }