I have a list of input images of which I'm trying to stack and get all the brightest pixels. At the moment I'm reading the first file and setting that as the base file, if a pixel in the next read image is brighter then it overwrites the first base image bitmap. It performs okay for low resolution images but larger images take much much longer as there can be 12,000,000 pixels in a 3000x4000 image. Would it be better for me to read the files as some sort of array instead of storing them as a bitmap? Speed is the essence here and I'm not too sure of how I can go about achieving the most efficient method to stack these images? For Each Item As String In lbxFiles.Items Dim newDrawing As System.Drawing.Bitmap = System.Drawing.Bitmap.FromFile(Item) For xCount As Integer = 0 To imageWidth - 1 For yCount As Integer = 0 To imageHeight - 1 baseColour = baseDrawing.GetPixel(xCount, yCount) newColour = newDrawing.GetPixel(xCount, yCount) If newColour.GetBrightness >= baseColour.GetBrightness Then newDrawing.SetPixel(xCount, yCount, newColour) End If Next yCount Next xCount Next Code (markup):
If speed is the essence you use assembly, not VB. You're asking whether you should use regular skates or inline skates to travel from Alaska to Peru. There's not going to be much difference if you stick with VB. It's not especially fast.
I see you are comparing each pixel from one image to another. Why every pixel ? Just take like 10 random pixels at the same location (x,y) in 2 pictures. There is a very very small chance that 2 different pictures have 10 same pixels on exactly the same place. By doing that you will only do 10 .getpixels for each image instead of a for loop that loops trough the whole picture.