MapWindow 4 - Plugins : MapWindow Discussion Forum
Hi All, I am trying to implement an image rectification option into ImgRegPlugin. Input: aerial photo as *,jpg with RGB data (24 bit) and Image WorldFile. I use Image.GetRow(...) to retreive pixel data row by row from the aerial photo to asign pixel by pixel to
Image.GetRow ?? Image.Value(i,j) As Integer ???
Posted by:
gngdowid ()
Date: March 05, 2010 09:45PM
Hi All,
I am trying to implement an image rectification option into ImgRegPlugin.
Input: aerial photo as *,jpg with RGB data (24 bit) and Image WorldFile.
I use Image.GetRow(...) to retreive pixel data row by row from the aerial photo to asign pixel by pixel to new rectified image as RecImage.Value(i,j) = ...
Problem: 24 bit RGB data requires at least 3 byte while Image.GetRow and Image.Value work on 2 byte integer pixel data.
Is this a possible bug in MapWinGIS.Image?
Below a simplified code sample of how I think it should work:
But g_Map.Layers.Add(RecImage) shows an image of roughly 1/5 the expected size, strangely with apperently correct pixel colors.
Any idea what is wrong or if we have a bug?
Cheers, Gerd
I am trying to implement an image rectification option into ImgRegPlugin.
Input: aerial photo as *,jpg with RGB data (24 bit) and Image WorldFile.
I use Image.GetRow(...) to retreive pixel data row by row from the aerial photo to asign pixel by pixel to new rectified image as RecImage.Value(i,j) = ...
Problem: 24 bit RGB data requires at least 3 byte while Image.GetRow and Image.Value work on 2 byte integer pixel data.
Is this a possible bug in MapWinGIS.Image?
Below a simplified code sample of how I think it should work:
Dim RecImage, OldImage As New MapWinGIS.Image
Dim success As Boolean = True
Dim Row As Integer
Dim Pixels() As Integer
Dim i, j As Integer
' more code here (not shown)
' Open old image
OldImage.Open(ImgFileName)
' Create new Image Layer for rectified image
success = RecImage.CreateNew(OldImage.Width, OldImage.Height)
If Not success Then
MsgBox("Could not create rectified Image Layer")
Else
Row = 0
ReDim Pixels(OldImage.Width)
' Just copy image at this stage, rectification code to come later. (as shown in Wiki)
For i = 0 To OldImage.Height - 1
OldImage.GetRow(Row, Pixels(0))
For j = 0 To OldImage.Width - 1
RecImage.Value(i, j) = Pixels(j)
Next
Row = Row + 1
Next
g_Map.Layers.Add(RecImage)
End If
But g_Map.Layers.Add(RecImage) shows an image of roughly 1/5 the expected size, strangely with apperently correct pixel colors.
Any idea what is wrong or if we have a bug?
Cheers, Gerd
Re: Image.GetRow ?? Image.Value(i,j) As Integer ???
Posted by:
Bartel ()
Date: June 25, 2010 09:52AM
I've been struggling today with an analogous problem and I think I've found a solution:
try to set RecImage.dX = OldImage.dX and same for dY before copying the data.
try to set RecImage.dX = OldImage.dX and same for dY before copying the data.
Sorry, only registered users may post in this forum.


