Added some colour averaging in the TFDisplayFX spectrgoram

This commit is contained in:
Jamie Mac 2022-03-03 08:25:20 +00:00
parent 203bff0325
commit 1cafec93e6
2 changed files with 16 additions and 5 deletions

View File

@ -125,8 +125,6 @@ public class ClickFFTPlotManager2 extends FFTPlotManager {
double[] minMax=PamUtils.getMinAndMax(spectrum);
double cutOff=clickPlotInfoFX.getClickDisplayParams().fftCutOf*minMax[1];
double binSize = maxFreq/(double) spectrum.length;
// System.out.println("cutOff: "+cutOff+ " fftCutOf: " + clickDisplayParams.fftCutOf);
int y1, y2;
@ -144,8 +142,6 @@ public class ClickFFTPlotManager2 extends FFTPlotManager {
y1=writableImage.getScrollingPLot2DSegmenter().getImageYPixels(0, writableImage);
y2=writableImage.getScrollingPLot2DSegmenter().getImageYPixels(maxFreq, writableImage);
strokeLine(writableImage, tc, y1, y2, ffColor);
}

View File

@ -348,6 +348,9 @@ public abstract class FFTPlotManager {
//how many lines in the image does the FFT take up?
Color prevCol;
Color col = null;
int argb;
for (int j=0; j<writableImage.getHeight(); j++) {
writableImage.getPixelWriter().setColor(0, j, Color.BLACK);
@ -360,7 +363,19 @@ public abstract class FFTPlotManager {
//find the correct colour for the spectrogram value and draw
for (int k=0; k<nslices; k++) {
if ((tc+k)>=writableImage.getWidth()) continue;
writableImage.getPixelWriter().setColor(tc+k, j, getSpectrumColour(spectrogram[i][spec], clipLevel, rawClipInfo.getDataBlock().getSampleRate(), fftLength));
//what do we do if a colour is already there? Take an avaerge with the other colours...
argb = writableImage.getPixelReader().getArgb(tc+k, j);
col = getSpectrumColour(spectrogram[i][spec],clipLevel, rawClipInfo.getDataBlock().getSampleRate(), fftLength);
if (argb>0) {
prevCol = Color.rgb((argb >> 16) & 0xFF, (argb >> 8) & 0xFF, (argb) & 0xFF);
col = Color.rgb((int) (col.getRed()+prevCol.getRed())/2, (int) (col.getGreen()+prevCol.getGreen())/2,
(int) (col.getBlue()+prevCol.getBlue())/2);
}
writableImage.getPixelWriter().setColor(tc+k, j, col);
}
}
// }