Hi, I'm new to both VB .net & LeadTools, and could use some advice. I'm using LT Raster 14 (COM objects) in VB .net 2003.
I need to do the following for several JPG images (about 500 on average) that are each 2048x1360 pixels -
Open the image, perform some simple math, like calculate a ratio between the RGB bands (e.g. G +B / G-B) and write a new JPG that contains the results. It all sounds really straight forward, but performance seems to be an issue...it takes about 8 minutes to do this per image using the following code (adapted for .net from a sample found on the lead support pages) -
imgInput = New LEADLib.LEAD
imgInput.Load(arImageList(intLoop), 0, 0, 1) 'arImageList is a string array of file names
'copy the input for the classified image & fill with 0
imgClass = New LEADLib.LEAD
imgClass.CreateBitmap(intCol, intRow, imgInput.BitmapBits)
imgClass.Fill(Convert.ToUInt32(RGB(Convert.ToInt32(0), Convert.ToInt32(0), Convert.ToInt32(0))))
intRow = imgInput.BitmapHeight
intCol = imgInput.BitmapWidth
For intX = 1 To intRow
For intY = 1 To intCol
color = Convert.ToInt64(imgInput.Pixel(intX, intY))
blue = (color) \ (2 ^ 16)
green = (color \ 256) And (&HFF)
red = color And (&HFF)
'**** IMAGE Band Ratio ALGORITHM HERE
'if ratio meets a threshold, output should be1 otherwise leave 0
imgClass.Pixel(intX, intY) = Convert.ToUInt32(RGB(1, 1, 1))
Next 'next column
Next 'next row
'*** save classified image
imgClass.Save(strOutputFilename, LEADLib.FileConstants.FILE_JPEG, 8, 2, LEADLib.SaveModifyConstants.SAVE_OVERWRITE)
This works, but as I said is slow ( and the end users will probably have older & slower PCs than mine). So...is there a better way to get to each pixel in an image? Does Load() simply read pixel by pixel from the hard disk? Would LoadArray() work better? If so how do you determine the size for the vMem parameter? I've used both the InfoSizeDisk and InfoSizeMem properties but neither seem to work (I get cannot read past end of file errors).
Any and all suggestions would be appreciated. Thanks!
Terry