//Lab4 functions:
 private void btnApplyMorph_Click(object sender, EventArgs e)
 {
     try
     {
         morfOperation morfOperation = (morfOperation)cbMorphOperations.SelectedIndex;
         structElement structElement = (structElement)cbStructElementsMorph.SelectedIndex;
         edgeMethods   edgeMethod;
         if (cbEdgeMethodsMorph.SelectedIndex == 0)
         {
             edgeMethod = edgeMethods.second;
         }
         else
         {
             edgeMethod = edgeMethods.mine;
         };
         mainImage.MorgologicOperation(morfOperation, structElement, edgeMethod);
         InvalidateImage();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Apply morph operation");
     }
 }