Ускоряет ли преобразование растрового изображения в градациях серого, является ли OpenMP опцией в C #?

Пожалуйста, помогите мне сделать этот код параллельным, используя openmp. Этот код запускается при нажатии кнопки, и текстовое поле имеет значение 128

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IMG
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    string path = "";
    public void openimage()
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            path = openFileDialog1.FileName;
            Graphics g = this.CreateGraphics();
            g.Clear(this.BackColor);
            Bitmap curBitmap = new Bitmap(path);
            g.DrawImage(curBitmap, 200, 220, 200, 200);
        }
    }
    Bitmap bm;
    Bitmap gs;
    private void button1_Click(object sender, EventArgs e)
    {
        if (path == "")
        {
            openimage();
        }

        //mack image gray scale
        Graphics g = this.CreateGraphics();
        g.Clear(this.BackColor);
        // Create a Bitmap object
        bm = new Bitmap(path);
        // Draw image with no effects
        g.DrawImage(bm, 200, 220, 200, 200);


        gs = new Bitmap(bm.Width, bm.Height);
        for (int i = 0; i < bm.Width; i++)
        {
            for (int j = 0; j < bm.Height; j++)
            {
                Color c = bm.GetPixel(i, j);
                int y = (int)(0.3 * c.R + 0.59 * c.G + 0.11 * c.B);
                gs.SetPixel(i, j, Color.FromArgb(y, y, y));
            }
        }

        // Draw image with no effects
        g.DrawImage(gs, 405, 220, 200, 200);


        for (int i = 0; i < gs.Width; i++)
        {
            for (int j = 0; j < gs.Height; j++)
            {
                Color c = gs.GetPixel(i, j);
                int y1 = 0;

                if (c.R >= Convert.ToInt16(textBox19.Text))
                    y1 = 255;
                bm.SetPixel(i, j, Color.FromArgb(y1, y1, y1));

            }
        }
        g.DrawImage(bm, new Rectangle(610, 220, 200, 200), 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel);
        // Dispose of objects
        gs.Dispose();

        g.Dispose();
    }
 }
}

Пожалуйста, помогите мне, как только вы сможете поверить в этот сайт и всех программистов здесь

Ответы на вопрос(2)

Ваш ответ на вопрос