Parallel openmp c?

You'll hit a couple of speed-bumps if OpenMP is on your radar. OpenMP is a multi-threading library for unmanaged C/C++, it requires compiler support to be effective. Not an option in C#.

Up vote 0 down vote favorite share g+ share fb share tw.

Please help me to make this code parallel using openmp this code is run on button click and the text box is 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 = 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(); } } } please help me as soon as you can I believe in this site and all programmers here... c# image-processing parallel openmp link|improve this question asked Jan 10 '10 at 22:13Firas276 50% accept rate.

The OpenMP spec covers only C, C++, and Fortran. No C#, and AFAIK Microsoft has not implemented anything like that in their C# compiler either. – janneb Jan 10 '10 at 22:48.

You'll hit a couple of speed-bumps if OpenMP is on your radar. OpenMP is a multi-threading library for unmanaged C/C++, it requires compiler support to be effective. Not an option in C#.

Let's take a step back. What you've got now is as bad as you can possibly get. Get/SetPixel() is dreadfully slow.

A major step would be to use Bitmap.LockBits(), it gives you an IntPtr to the bitmap bits. You can party on those bits with an unsafe byte pointer. That will be at least an order of magnitude faster.

Let's take another step back, you are clearly writing code to convert a color image to a gray-scale image. Color transforms are natively supported by GDI+ through the ColorMatrix class. That code could look like this: public static Image ConvertToGrayScale(Image srce) { Bitmap bmp = new Bitmap(srce.

Width, srce. Height); using (Graphics gr = Graphics. FromImage(bmp)) { var matrix = new float { new float { 0.299f, 0.299f, 0.299f, 0, 0 }, new float { 0.587f, 0.587f, 0.587f, 0, 0 }, new float { 0.114f, 0.114f, 0.114f, 0, 0 }, new float { 0, 0, 0, 1, 0 }, new float { 0, 0, 0, 0, 1 } }; var ia = new System.Drawing.Imaging.ImageAttributes(); ia.

SetColorMatrix(new System.Drawing.Imaging. ColorMatrix(matrix)); var rc = new Rectangle(0, 0, srce. Width, srce.

Height); gr. DrawImage(srce, rc, 0, 0, srce. Width, srce.

Height, GraphicsUnit. Pixel, ia); return bmp; } } Credit to Bob Powell for the above code.

If so, I think before turning this code parallel you can try a different approach in the way you are accessing the pixel information in your image. The way you are doing in this code is very slow. You may try to process your image using unsafe code to access the pixels of the Bitmap class.

Take a look at this thread to see what I'm talking about.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions