/// <summary> /// Изменить сэмплинг данных на новый. Лучше использовать внешние средства /// </summary> public SonoBuilder Resample(int NewSampleRate) { SonoBuilder result = new SonoBuilder(); float coeff = ((float)NewSampleRate) / SampleRate; int[] dataResult = new int[(int)(coeff * Data.Length)]; Resample(ref dataResult); result.Data = dataResult; result.SampleRate = NewSampleRate; return result; }
/// <summary> /// Build footprints by sonoram /// </summary> /// <param name="Sono">Sonogram</param> public static uint[] GetPrintsFromSono(float[][] Sono) { int halfDepth = Sono[0].Length; const int Size = 33; // sizeof(uint) + 1; // Get pows (summ of squares) float[][] pows = new float[Sono.Length][]; float dfstep = halfDepth / Size, fstep = 0; uint[] prints = new UInt32[pows.Length - 1]; for (int i = 0; i < Sono.Length; i++) { pows[i] = new float[Size]; fstep = 0; for (int j = 0; j < Size; j++) { for (int k = (int)fstep; k < fstep + dfstep; k++) { pows[i][j] += Sono[i][k] * Sono[i][k]; } fstep += dfstep; } } #if DEFINE_OUTPUT float[][] img = new float[pows.Length][]; for(int i=0;i<img.Length;i++) img[i] = new float[pows[0].Length]; #endif //for (int i = 0; i < Size - 1; i++) pows[0][i] -= pows[0][i + 1]; for (int i = 1; i < pows.Length; i++) { uint key = 1, val = 0; for (int j = 0; j < Size - 1; j++) { //pows[i][j] -= pows[i][j + 1]; if (pows[i - 1][j] > pows[i][j]) { val |= key; #if DEFINE_OUTPUT img[i][j] = 255; #endif } key <<= 1; } prints[i - 1] = val; } #if DEFINE_OUTPUT SonoBuilder sono = new SonoBuilder(); Bitmap bmp = sono.FillBmp(img); bmp.Save(DateTime.Now.ToShortDateString() + ".bmp"); #endif return prints; }