Undistort Border calculation [closed]

asked 2012-07-21 08:21:24 -0500

BIM gravatar image

updated 2012-07-21 11:26:01 -0500

Hallo, Hallo

I have have a good Image when I use the undistort- function on the Image. My problem is, that I lose to many Image-information (area). I think the problem is, that the new undistort-image has the same size as the original. My idea was to enlarge the original image and to see the full image content. The problem is calculating the needed border. Here is my Code:

Dim P(1) As PointF ‘Corner from the Image
Dim fx As Double = myIntrinsicParam.IntrinsicMatrix(0, 0)
Dim fy As Double = myIntrinsicParam.IntrinsicMatrix(1, 1)
Dim cx As Double = myIntrinsicParam.IntrinsicMatrix(0, 2) ‘Refpoint in X
Dim cy As Double = myIntrinsicParam.IntrinsicMatrix(1, 2) ‘Refpoint in Y

P(0).X = 0
P(0).Y = 0
P(1).X = ImageSize.Width
P(1).Y = ImageSize.Height

P = myIntrinsicParam.Undistort(P, Nothing, Nothing)
Dim i As Integer
‘multiplication to camera matrix px = px * fx + cx; py = py * fy + cy; } 

For i = 0 To P.Length – 1
P(i).X = CSng(P(i).X * fx + cx)
P(i).Y = CSng(P(i).Y * fy + cy)
Next
UndistortBorder = New Rectangle(CInt(-P(0).X), CInt(-P(0).Y), CInt(P(1).X – P(0).X), CInt(P(1).Y – P(0).Y))

I wanted to calculate the new image size and offset.

Dim BorderColor As MCvScalar = New MCvScalar(0, 0, 0) ‘Black
Dim ImageLarge As Image(Of Gray, Byte)
ImageLarge = New Image(Of Gray, Byte)(UndistortBorder.Width, UndistortBorder.Height)

CvInvoke.cvCopyMakeBorder(image.Ptr, ImageLarge.Ptr, UndistortBorder.Location, CvEnum.BORDER_TYPE.CONSTANT, BorderColor)

With this solution is my calculated offset too big. What is my fault ?

Mike

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2016-01-04 23:26:28.774833

Comments

2

Hi Mike, your question seems interesting but can you please edit and correct the text of your question, it is a bit unreadable.

Rui Marques gravatar imageRui Marques ( 2012-07-21 08:25:52 -0500 )edit