From 1cafec93e68b31af24663774912548694b47bd74 Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Thu, 3 Mar 2022 08:25:20 +0000 Subject: [PATCH] Added some colour averaging in the TFDisplayFX spectrgoram --- .../clickPlotFX/ClickFFTPlotManager2.java | 4 ---- src/dataPlotsFX/data/FFTPlotManager.java | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/dataPlotsFX/clickPlotFX/ClickFFTPlotManager2.java b/src/dataPlotsFX/clickPlotFX/ClickFFTPlotManager2.java index af8ba13c..a5c2e8d3 100644 --- a/src/dataPlotsFX/clickPlotFX/ClickFFTPlotManager2.java +++ b/src/dataPlotsFX/clickPlotFX/ClickFFTPlotManager2.java @@ -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); } diff --git a/src/dataPlotsFX/data/FFTPlotManager.java b/src/dataPlotsFX/data/FFTPlotManager.java index 9163aa96..8ecf5f28 100644 --- a/src/dataPlotsFX/data/FFTPlotManager.java +++ b/src/dataPlotsFX/data/FFTPlotManager.java @@ -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.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); } } // }