Note that there are some explanatory texts on larger screens.

plurals
  1. POImproving Image compositing Algorithm c# .NET
    primarykey
    data
    text
    <p>I was wondering if anyone could shed some light on improvements I can do in making this compositing algorithm faster. What is does is takes 3 images splits them up to get the 1st Images Red Channel, 2nd Images Green channel and the 3rd Images Blue channel and composites them together into 1 new image. Now it works but at an excruciatingly slow pace. The reason i think down to the pixel by pixel processing it has to do on all image components.</p> <p>The process is to : </p> <p>For all images: Extract respective R G and B values -> composite into 1 image -> Save new Image.</p> <pre><code>foreach (Image[] QRE2ImgComp in QRE2IMGArray) { Globals.updProgress = "Processing frames: " + k + " of " + QRE2IMGArray.Count + " frames done."; QRMProgressUpd(EventArgs.Empty); Image RedLayer = GetRedImage(QRE2ImgComp[0]); QRE2ImgComp[0] = RedLayer; Image GreenLayer = GetGreenImage(QRE2ImgComp[1]); QRE2ImgComp[1] = GreenLayer; Image BlueLayer = GetBlueImage(QRE2ImgComp[2]); QRE2ImgComp[2] = BlueLayer; Bitmap composite = new Bitmap(QRE2ImgComp[0].Height, QRE2ImgComp[0].Width); Color Rlayer,Glayer,Blayer; byte R, G, B; for (int y = 0; y &lt; composite.Height; y++) { for (int x = 0; x &lt; composite.Width; x++) { //pixelColorAlpha = composite.GetPixel(x, y); Bitmap Rcomp = new Bitmap(QRE2ImgComp[0]); Bitmap Gcomp = new Bitmap(QRE2ImgComp[1]); Bitmap Bcomp = new Bitmap(QRE2ImgComp[2]); Rlayer = Rcomp.GetPixel(x, y); Glayer = Gcomp.GetPixel(x, y); Blayer = Bcomp.GetPixel(x, y); R = (byte)(Rlayer.R); G = (byte)(Glayer.G); B = (byte)(Blayer.B); composite.SetPixel(x, y, Color.FromArgb((int)R, (int)G, (int)B)); } } Globals.updProgress = "Saving frame..."; QRMProgressUpd(EventArgs.Empty); Image tosave = composite; Globals.QRFrame = tosave; tosave.Save("C:\\QRItest\\E" + k + ".png", ImageFormat.Png); k++; } </code></pre> <p>For reference here is the red channel filter method relatively the same for blue and green:</p> <pre><code>public Image GetRedImage(Image sourceImage) { Bitmap bmp = new Bitmap(sourceImage); Bitmap redBmp = new Bitmap(sourceImage.Width, sourceImage.Height); for (int x = 0; x &lt; bmp.Width; x++) { for (int y = 0; y &lt; bmp.Height; y++) { Color pxl = bmp.GetPixel(x, y); Color redPxl = Color.FromArgb((int)pxl.R, 0, 0); redBmp.SetPixel(x, y, redPxl); } } Image tout = (Image)redBmp; return tout; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload