Page 1 of 1

Annotation Measurement Units

Posted: Fri Jan 27, 2012 4:14 pm
by RobertHorn
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

Re: Annotation Measurement Units

Posted: Fri Jan 27, 2012 5:48 pm
by Loïc
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

Re: Annotation Measurement Units

Posted: Fri Feb 03, 2012 6:35 pm
by RobertHorn
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?

Re: Annotation Measurement Units

Posted: Sun Feb 05, 2012 2:23 pm
by Loïc
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

Re: Annotation Measurement Units

Posted: Wed Oct 05, 2016 1:46 am
by ElkayEQ
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