// click on processing buttons private void Button_Click(object sender, RoutedEventArgs e) { string buttonName = (sender as Button).Name.ToString(); ImageProcessing process = new ImageProcessing(); byte[] processedImageBytes; switch (buttonName[0]) { // if the button is "Binary" case 'b': processedImageBytes = process.setBinary(originalImageBytes); processedPanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 1); break; // if the button is "Erosion" case 'e': processedImageBytes = process.setErosion(originalImageBytes); processedPanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 1); break; // if the button is "Dilatation" case 'd': processedImageBytes = process.setDilatation(originalImageBytes); processedPanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 1); break; // if the button is "Edge" case 'c': processedImageBytes = process.setEdges(originalImageBytes); processedPanel.Source = ImageConvertor.ByteArrayToImage(processedImageBytes, originalImage.PixelWidth, originalImage.PixelHeight, 1); break; // if smth stupid happend default: break; } }
// show image on the window private void showImage(string filename) { originalImage = ImageConvertor.FilenameToImage(filename); originalImageBytes = ImageConvertor.ImageToByteArray(filename); originalPanel.Source = originalImage; }