Классификация LPI-сигналов
Автор
function show_sample(data, n, hop, Fs, nfft)
s = SignalAnalysis.spectrogram(data, n, hop; window=hanning(n), nfft=nfft, fs = Fs, onesided=false)
t = time(s) .* 1e6
f = freq(s)
inds = sortperm(f)
f = f[inds] .*1e-6
z = power(s)[inds, :]
z = pow2db.(abs.(z))
fig = heatmap(t, f, z;
xlabel="Time (ms)",
ylabel="Frequency (kHz)",
colorbar_title="dB")
return z, fig
end
function getImage(z)
cmax = ceil(maximum(z)/5)*5
cmin = cmax - 50
clims = (cmin, cmax)
zmin, zmax = minimum(z), maximum(z)
zn = (z .- zmin) ./ (zmax .- zmin)
img_rgb = similar(zn, RGB{Float32})
for I in CartesianIndices(zn)
i, j = Tuple(I)
img_rgb[end-i+1, j] = ColorSchemes.alpine[zn[i,j]]
end
img_rgb = imresize(img_rgb, (224, 224))
return img_rgb
end
function getBinary(img_rgb, threshold)
gray_img = Gray.(img_rgb)
binary_thresh = Gray.(gray_img .> threshold)
return binary_thresh
end
function calcHoG(bnr)
img_f = Float32.(bnr)
features = create_descriptor(img_f, HOG())
return features
end