Skip to content
Prev Previous commit
Next Next commit
Compare hsv to rgb
  • Loading branch information
janezdu committed Jul 6, 2021
commit 77085b5d322effbcc0239a0f3483d2600cff83f9
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
HorizontalAlignment="Center" VerticalAlignment="Center" />

<StackPanel HorizontalAlignment="Center" Background="White" Orientation="Horizontal">
<Image Name="spectrogram" Stretch="Fill" Height="500" Width="500" />
<Image Name="spectrogramComputational" Stretch="Fill" Height="500" Width="300" />
<Image Name="spectrogramBitmapEdited" Stretch="Fill" Height="500" Width="300" />
</StackPanel>
</StackPanel>
</Window>
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,28 @@ public MainWindow()
{
InitializeComponent();
ViewModel = new PreprocessViewModel();
spectrogram.Source = new SoftwareBitmapSource();
spectrogramComputational.Source = new SoftwareBitmapSource();
spectrogramBitmapEdited.Source = new SoftwareBitmapSource();
}

public PreprocessViewModel ViewModel { get; set; }
private async void OnOpenClick(object sender, RoutedEventArgs e)
{
string wavPath = await GetFilePath();
PreprocessModel melSpectrogram = new PreprocessModel();
var softwareBitmap = melSpectrogram.GenerateMelSpectrogram(wavPath, ColorMelSpectrogramCheckBox.IsChecked ?? false);
//PreprocessModel.Colorize(VideoFrame.CreateWithSoftwareBitmap(softwareBitmap), 0.5f, 0.3f);

bool colorize = ColorMelSpectrogramCheckBox.IsChecked ?? false;
// Use bitmap editing, pixel by pixel, to colorize image, if box is checked
SoftwareBitmap softwareBitmap = melSpectrogram.GenerateMelSpectrogram(wavPath, colorize);
// Use computational graph to colorize image, if box is checked
SoftwareBitmap computationalSoftwareBitmap;
if (colorize)
{
computationalSoftwareBitmap = PreprocessModel.ColorizeWithComputationalGraph(VideoFrame.CreateWithSoftwareBitmap(softwareBitmap), 0.7f, 0.5f);
}
else
{
computationalSoftwareBitmap = softwareBitmap;
}
ViewModel.AudioPath = wavPath;
ViewModel.MelSpectrogramImage = softwareBitmap;

Expand All @@ -56,7 +67,8 @@ private async void OnOpenClick(object sender, RoutedEventArgs e)

WavFilePath.Text = ViewModel.AudioPath;

await ((SoftwareBitmapSource)spectrogram.Source).SetBitmapAsync(softwareBitmap);
await ((SoftwareBitmapSource)spectrogramComputational.Source).SetBitmapAsync(softwareBitmap);
await ((SoftwareBitmapSource)spectrogramBitmapEdited.Source).SetBitmapAsync(computationalSoftwareBitmap);
}

private async Task<string> GetFilePath()
Expand Down
Loading