Annotation Measurement Units

Discussions about annotation support.
Post Reply
RobertHorn
Posts: 14
Joined: Fri Jan 20, 2012 8:18 am

Annotation Measurement Units

Post by RobertHorn » Fri Jan 27, 2012 4:14 pm

Hi,

I am using Annotations to allow a user to select an area that is then used later to Zonal OCR.

Up to now, when working with the positions on the image, the values that I get for things like Page Width are in the 1000's. Now when I check the Top, Left, Width and Height of the Annotation, I find that the values are incredibly small. A possition of 5 is in the middle of the page. So how do I translate these position so that I can then use them to do the Zonal OCR?

Robert

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Annotation Measurement Units

Post by Loïc » Fri Jan 27, 2012 5:48 pm

Hi,

Just scale the inch size by the image resolution.

IE:

Code: Select all

int widthPixel = Math.Round(widthInches * horizontalResolution);
int heightPixel = Math.Round(heightInches *verticalResolution);
Kind regards,

Loïc

RobertHorn
Posts: 14
Joined: Fri Jan 20, 2012 8:18 am

Re: Annotation Measurement Units

Post by RobertHorn » Fri Feb 03, 2012 6:35 pm

Hi Loic,

I have done the following to workout the exact pixels of the image where the annotation is:

HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution

PixTop = AnnotationTop / VertialResolution
PixHeight = AnnotationHeight / VertialResolution
PixWidth = AnnotationWidth / HorizontalResolution
PixLeft = AnnotationLeft / HorizontalResolution

I then draw a rectangle:

oGdPictureImaging.DrawRectangle(ImageID, PixLeft, PixTop, PixWidth, PixHeight, 10, Color.Red, True)

Now when I reposition the annotation with these fixures, it is where it should be. But if draw a rectangle on this image using these figures, the rectangle is off to the left and slighly down. It is not in the same position as the Annotation. Now the GD Viewer has functionality that enables you to select what area you want to process. But using the Rectangle Annotation provides a really nice way of enabling the user to edit the size and position of the area. So I am trying to integrate the two so that I can then process the area selected.

So my question is, how do I translate the position of the Annotations so that I get an accurate rectangle on the image?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Annotation Measurement Units

Post by Loïc » Sun Feb 05, 2012 2:23 pm

Hi,

Please have a look on the reference guide.
Especially here:

Left: Left position, in inches, of the middle point of the bounding box of the annotation.
Top: Top position, in inches, of the middle point of the bounding box of the annotation.
Width: Width, in inches, of the bounding box of the annotation.
Height: Height, in inches, of the bounding box of the annotation.
So the top-left corner of the annotation bbox is:

Code: Select all

topLeftX = annot.Left - annot.Width/2
topLeftY = annot.Top - annot.Height/2
Hope this helps.

Kind regards,

Loïc

ElkayEQ
Posts: 16
Joined: Tue Oct 06, 2015 6:43 am

Re: Annotation Measurement Units

Post by ElkayEQ » Wed Oct 05, 2016 1:46 am

Since Horizontal and VerticalResolution are "Pixels per inch" and Left, Top, Width, Height are all in inches...shouldn't your calculation to convert to pixels look like this:

HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution

PixTop = AnnotationTop * VertialResolution
PixHeight = AnnotationHeight * VertialResolution
PixWidth = AnnotationWidth * HorizontalResolution
PixLeft = AnnotationLeft * HorizontalResolution

Just a thought :)
-C

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest