PDA

View Full Version : get min and max value from spectrogram



rambo83
1st December 2009, 15:28
Hello,

I would like to adapt the colormap in regard to the max and min values of intensity ( in a spectrogram). How can it be done?

here the colormap is set:


QwtValueList contourLevels;
for ( double level = 0.5; level < 10.0; level += 1.0 )
contourLevels += level;
d_spectrogram->setContourLevels(contourLevels);

// A color bar on the right axis
QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
rightAxis->setTitle("Intensity");
rightAxis->setColorBarEnabled(true);
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());

setAxisScale(QwtPlot::yRight,
d_spectrogram->data().range().minValue(),
d_spectrogram->data().range().maxValue() );
enableAxis(QwtPlot::yRight);

and my QwtData is:


typedef double (*benchFunc)(double, double); // definition of function pointer for benchmark function

class SpectrogramData: public QwtRasterData
{
public:
SpectrogramData(benchFunc b, double rang1[2], double rang2[2]):
QwtRasterData(QwtDoubleRect(rang1[0], rang2[0], rang1[1]- rang1[0], rang2[1]- rang2[0]))
{
MybenchFunc = b;
rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
}

virtual QwtRasterData *copy() const
{
return new SpectrogramData(*this);
}

virtual QwtDoubleInterval range() const
{
return QwtDoubleInterval(-5.0, 5.0);
}

virtual double value(double x, double y) const
{

const double result = MybenchFunc(x,y);
return result;
}

private:

benchFunc MybenchFunc; // function pointer for benchmark function
double rangeX1[2];
double rangeX2[2];
};

At the moment the range is set to (-5, 5), but it is fix. I want to make it dynamical.

Thanks for help.

best regards,

Vitali

rambo83
2nd December 2009, 14:25
just for your information - this problem is already solved... :)