Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, June 14, 2011 9:29:52 AM(UTC)

emhj  
emhj

Groups: Registered
Posts: 7


Hi,

I was wondering if there were a simple way of determining the transformation parameters if just running the Deskew command?  I am trying to apply post processing information back to the original image (e.g. where lines were detected in an OCR'd image).

I am working with .NET and tried to follow the documentation for using the GetTransformationParameters() method, but this proved more difficult than I realized.  It could be that I am not executing the suggested commands in the right order.  Below is a small snippet of code:

rmData = new SearchRegistrationMarksCommandData[3];

// setup rmData[0] slightly to left and above of center
...
// setup rmData[1] slightly to right and above of center
...
// setup rmData[2] slightly to below of center
...

// find marks
SearchRegistrationMarksCommand comm = new SearchRegistrationMarksCommand(rmData);
comm.Run(m_image);

// calculate center of mass
LeadPoint[] originals = new LeadPoint[3];

originals[0] = rmData[0].MarkDetectedPoints[0];
originals[1] = rmData[1].MarkDetectedPoints[0];
originals[2] = rmData[2].MarkDetectedPoints[0];

LeadPoint[] originalCenterOfMass = new LeadPoint[3];
           
originalCenterOfMass = CoreUtilities.GetRegistrationMarksCenterMass(m_image, originals);

// deskew
DeskewCommand command = new DeskewCommand();
command.Flags = DeskewCommandFlags.DeskewImage | DeskewCommandFlags.DoNotFillExposedArea;
command.Run(m_image);

// calculate transformation parameters
LeadPoint[] detected = new LeadPoint[3];

detected[0] = rmData[0].MarkDetectedPoints[0];
detected[1] = rmData[1].MarkDetectedPoints[0];
detected[2] = rmData[2].MarkDetectedPoints[0];

LeadPoint[] transformed = CoreUtilities.GetRegistrationMarksCenterMass(m_image, detected);

TransformationParameters parameters = CoreUtilities.GetTransformationParameters(
    m_image,
    originalCenterOfMass,
    transformed
);


This does not work as I had hoped.

Thanks,
Eric
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, June 15, 2011 8:06:10 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Eric,
Registration marks and Deskew are used for similar goals, but in very different ways. You should use one or the other, but not both together.
Deskew mainly performs analysis of horizontal lines of text to determine the angle of skewing in the image. It can either rotate the image by a relatively small number of degrees, or you can instruct it not to do the rotation, but to return the angle to you.
Registration marks functions require that your forms be already imprinted with special T-shaped marks at appropriate locations on them before they are scanned. Do your images have these shapes on them?

Also, which LEADTOOLS version (15, 16, 17, etc.) are you using?
 
#3 Posted : Wednesday, June 15, 2011 8:24:30 AM(UTC)

emhj  
emhj

Groups: Registered
Posts: 7


Hello Adnan,

I did not realize the registration marks function required the T-shape marks to already exist (I assumed these were virtual marks).  Requiring these marks a priori is not the intended functionality I was hoping for.

I have tried using the angle returned from the Deskew command to rotate any points on the deskewed image back to their original position in the skewed image, but it appears that there is also some translation going on between the two images as bounding boxes found via OCR are slightly off from the corresponding lines.  Is there anyway to confirm my suspicion?

I'm wondering if it could be that the deskew command performs pre-processing which may include changing the image dimensions?  Although the documentation does not indicate this type of functionality.

I am using a trial version of LEADTOOLS v17.

Thanks,
Eric
 
#4 Posted : Thursday, June 16, 2011 9:05:03 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Eric,
Deskewing does not involve resizing or translating. It only rotates.
If your images are of a limited number of forms, our Forms Recognition module can be used to automatically identify the form, and also correct for changes in scanning angle, position and size variations.
 
#5 Posted : Thursday, June 16, 2011 1:34:41 PM(UTC)

emhj  
emhj

Groups: Registered
Posts: 7


Adnan,

What is the rotation matrix used by LEADTOOLS?

Is it the counterclockwise rotation matrix:

cos(theta)  -sin(theta)  0
sin(theta)   cos(theta)  0
0               0               1

?

Attached you will find sample images using the bounding boxes generated by the Arabic OCR in both the original and deskewed image.  Notice that the boxes do not line up when rotated using the inverse of the rotation matrix previously mentioned.

Thanks,
Eric
File Attachment(s):
deskew.zip (200kb) downloaded 26 time(s).
 
#6 Posted : Sunday, June 19, 2011 6:10:32 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Eric,
When deskewing an image, all the pixels are rotated around the image's center point.
I looked at the 2 images you sent, and it appears the text parts were rotated around the center, but the boxes were rotated around some other point.
 
#7 Posted : Monday, June 20, 2011 12:02:14 PM(UTC)

emhj  
emhj

Groups: Registered
Posts: 7


Hey Adnan,

I am glad you mentioned that the rotation is through the center.  I did not think of this, but by using a delta between the center of the image and my calculated rotation, the bounding boxes were fixed.

I had assumed that the rotations were through the origin of the image (0, 0), and not the center.

Thanks for your help.

Eric
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.240 seconds.